private fun leaves(from: Int): LeavesIterator do return new LeavesIterator(self, from)
# Iterator on the substrings from 0, in forward order
- fun substrings: IndexedIterator[Text] do return new SubstringsIterator(self, 0)
+ redef fun substrings do return new SubstringsIterator(self, 0)
# Iterator on the substrings, starting at position `from`, in forward order
fun substrings_from(from: Int): IndexedIterator[Text] do return new SubstringsIterator(self, from)
# In this case, `from += count` and `count -= from`.
fun substring(from: Int, count: Int): SELFTYPE is abstract
+ # Iterates on the substrings of self if any
+ fun substrings: Iterator[Text] is abstract
+
# Concatenates `o` to `self`
#
# assert "hello" + "world" == "helloworld"
redef type SELFTYPE: String
redef fun to_s do return self
+end
+
+private class FlatSubstringsIter
+ super Iterator[FlatText]
+
+ var tgt: nullable FlatText
+
+ init(tgt: FlatText) do self.tgt = tgt
+ redef fun item do
+ assert is_ok
+ return tgt.as(not null)
+ end
+
+ redef fun is_ok do return tgt != null
+
+ redef fun next do tgt = null
end
# Immutable strings of characters.
return hash_cache.as(not null)
end
+
+ redef fun substrings do return new FlatSubstringsIter(self)
end
private class FlatStringReverseIterator
private var capacity: Int = 0
+ redef fun substrings do return new FlatSubstringsIter(self)
+
redef fun []=(index, item)
do
is_dirty = true