lib/standard/ropes: Preparing introduction of iterators on Rope.
authorLucas Bajolet <r4pass@hotmail.com>
Thu, 5 Jun 2014 14:24:56 +0000 (10:24 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Thu, 5 Jun 2014 18:17:06 +0000 (14:17 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/ropes.nit

index 940939d..d1f7398 100644 (file)
@@ -284,3 +284,25 @@ class RopeString
        end
 end
 
+# Used to iterate on a Rope
+private class IteratorElement
+
+       init(e: RopeNode)
+       do
+               if e isa Leaf then
+                       left = true
+                       right = true
+               end
+               node = e
+       end
+
+       # The node being visited
+       var node: RopeNode
+       # If the node has a left child, was it visited ?
+       var left = false
+       # If the node has a right child, was it visited ?
+       var right = false
+       # Was the current node visited ?
+       var done = false
+end
+