stdlib/strings: Access iterator through its position constructor.
authorLucas Bajolet <r4pass@hotmail.com>
Fri, 28 Feb 2014 20:11:33 +0000 (15:11 -0500)
committerLucas Bajolet <r4pass@hotmail.com>
Fri, 7 Mar 2014 19:51:05 +0000 (14:51 -0500)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/string.nit

index e1505df..524d4d4 100644 (file)
@@ -378,6 +378,10 @@ abstract class StringCharView
 
        redef fun length do return target.length
 
+       redef fun iterator: IndexedIterator[Char] do return self.iterator_from(0)
+
+       fun iterator_from(pos: Int): IndexedIterator[Char] is abstract
+
        redef fun has(c: Char): Bool
        do
                for i in self do
@@ -747,7 +751,7 @@ private class FlatStringCharView
                return target._items[index + target._index_from]
        end
 
-       redef fun iterator: IndexedIterator[Char] do return new FlatStringIterator.with_pos(target, 0)
+       redef fun iterator_from(start) do return new FlatStringIterator.with_pos(target, start)
 
 end
 
@@ -918,7 +922,7 @@ private class FlatBufferCharView
                if target.capacity < s.length then enlarge(s_length + target.length)
        end
 
-       redef fun iterator: IndexedIterator[Char] do return new FlatBufferIterator.with_pos(target, 0)
+       redef fun iterator_from(pos) do return new FlatBufferIterator.with_pos(target, pos)
 
 end