Class: LemonGraph::GraphItem
- Inherits:
-
Object
- Object
- LemonGraph::GraphItem
- Includes:
- Comparable
- Defined in:
- ext/lemongraph/graph_item.cc,
ext/lemongraph/lemongraph.cc
Overview
Base class for nodes, arcs and edges of directed or undirected graphs.
Direct Known Subclasses
Digraph::Arc, Digraph::Node, LemonGraph::Graph::Arc, LemonGraph::Graph::Edge, LemonGraph::Graph::Node
Instance Attribute Summary collapse
-
#graph ⇒ Digraph, Graph
readonly
The graph the item belongs to.
-
#id ⇒ Integer
readonly
The graph item's id.
Instance Method Summary collapse
- #!=(other) ⇒ Boolean
-
#<=>(other) ⇒ Boolean?
Compare self with another graph item.
-
#==(other) ⇒ Boolean
Returns true if other has the same class as self and self and other share the same graph and id.
Instance Attribute Details
#id ⇒ Integer (readonly)
Returns the graph item's id.
Instance Method Details
#!=(other) ⇒ Boolean
56 57 58 59 60 61 |
# File 'ext/lemongraph/graph_item.cc', line 56
VALUE lemongraph_graphitem_is_notequal(VALUE self, VALUE other)
{
if (rb_class_of(other) != rb_class_of(self))
return Qtrue;
return ((rb_iv_get(self, "@id") != rb_iv_get(other, "@id")) || (rb_iv_get(self, "@graph") != rb_iv_get(other, "@graph"))) ? Qtrue : Qfalse;
}
|
#<=>(other) ⇒ Boolean?
Compare self with another graph item.
Returns nil if other and self do not have the same class, else returns self.id <=> other.id.
69 70 71 72 73 74 |
# File 'ext/lemongraph/graph_item.cc', line 69
VALUE lemongraph_graphitem_compare(VALUE self, VALUE other)
{
if (rb_class_of(other) != rb_class_of(self) || rb_iv_get(self, "@graph") != rb_iv_get(other, "@graph"))
return Qnil;
return rb_funcall(rb_iv_get(self, "@id"), id_comp, 1, rb_iv_get(other, "@id"));
}
|
#==(other) ⇒ Boolean
Returns true if other has the same class as self and self and other share the same graph and id.
46 47 48 49 50 51 |
# File 'ext/lemongraph/graph_item.cc', line 46
VALUE lemongraph_graphitem_is_equal(VALUE self, VALUE other)
{
if (rb_class_of(other) != rb_class_of(self))
return Qfalse;
return ((rb_iv_get(self, "@id") == rb_iv_get(other, "@id")) && (rb_iv_get(self, "@graph") == rb_iv_get(other, "@graph"))) ? Qtrue : Qfalse;
}
|