Class: Neo4j::Core::RelationshipSet
- Inherits:
-
Object
- Object
- Neo4j::Core::RelationshipSet
- Defined in:
- lib/neo4j-core/relationship_set.rb
Overview
Represents a set of relationships.
See Neo4j::EventHandler
Instance Method Summary collapse
-
#add(rel) ⇒ Object
Adds a relationship to the set.
-
#contains?(end_node_id, relationship_type) ⇒ Boolean
Returns true if a relationship with the specified end_node_id and relationship_type is present in the set.
-
#contains_rel?(rel) ⇒ Boolean
Returns true if the specified relationship is in the set.
-
#initialize(size = 0) ⇒ RelationshipSet
constructor
A new instance of RelationshipSet.
-
#relationships(end_node_id) ⇒ Object
Returns a collection of relationships where the node with the specified end node id is the end node.
Constructor Details
#initialize(size = 0) ⇒ RelationshipSet
Returns a new instance of RelationshipSet.
6 7 8 9 10 |
# File 'lib/neo4j-core/relationship_set.rb', line 6 def initialize(size=0) @relationship_type_set = java.util.HashSet.new(size) @relationship_set = java.util.HashSet.new(size) @relationship_map = java.util.HashMap.new(size) end |
Instance Method Details
#add(rel) ⇒ Object
Adds a relationship to the set
13 14 15 16 17 |
# File 'lib/neo4j-core/relationship_set.rb', line 13 def add(rel) @relationship_type_set.add(RelationshipSetEntry.new(rel.getEndNode().getId(), rel.rel_type)) relationships(rel.getEndNode().getId()) << rel @relationship_set.add(rel.getId) end |
#contains?(end_node_id, relationship_type) ⇒ Boolean
Returns true if a relationship with the specified end_node_id and relationship_type is present in the set.
30 31 32 |
# File 'lib/neo4j-core/relationship_set.rb', line 30 def contains?(end_node_id, relationship_type) @relationship_type_set.contains(RelationshipSetEntry.new(end_node_id, relationship_type)) end |
#contains_rel?(rel) ⇒ Boolean
Returns true if the specified relationship is in the set
25 26 27 |
# File 'lib/neo4j-core/relationship_set.rb', line 25 def contains_rel?(rel) @relationship_set.contains(rel.getId) end |
#relationships(end_node_id) ⇒ Object
Returns a collection of relationships where the node with the specified end node id is the end node.
20 21 22 |
# File 'lib/neo4j-core/relationship_set.rb', line 20 def relationships(end_node_id) @relationship_map.get(end_node_id) || add_list(end_node_id) end |