# 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.
super FlatText
super String
- redef type SELFTYPE: FlatString
-
# Index in _items of the start of the string
private var index_from: Int
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