From 3f5a9e54d49bf38bcf0af287c5799cbfbd830f83 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Christophe=20Beaupr=C3=A9?= Date: Sat, 20 Dec 2014 13:35:57 -0500 Subject: [PATCH] neo4j/graph: Add node removal methods. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Christophe Beaupré --- lib/neo4j/graph/graph.nit | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/neo4j/graph/graph.nit b/lib/neo4j/graph/graph.nit index 48ec4ba..f403744 100644 --- a/lib/neo4j/graph/graph.nit +++ b/lib/neo4j/graph/graph.nit @@ -109,6 +109,35 @@ abstract class NeoNodeCollection register(node) return node end + + # Remove the node with the specified local ID. + fun remove_at(id: ID_TYPE) is abstract + + # Remove the specified node. + # + # The local ID is used instead of `==` to seek the node. + fun remove_node(node: NeoNode) do + remove_at(id_of(node)) + end + + redef fun clear do + for node in self do remove_node(node) + end + + redef fun remove(node: NeoNode) do + for n in self do + if node == n then + remove_node(n) + return + end + end + end + + redef fun remove_all(node: NeoNode) do + for n in self do + if node == n then remove_node(n) + end + end end # A mean to save and load a Neo4j graph. -- 1.7.9.5