#
# Basically just returns `self` encapsulated in a `FlatString`.
private class LeafSubstrings
- super IndexedIterator[Text]
+ super IndexedIterator[FlatText]
var leaf: Leaf
- var str: String is noinit
+ var str: FlatString is noinit
var avail = true
init do
# mutable native string (`ns`)
private var buf_size: Int is noinit
- redef fun substrings: Iterator[String] do return new RopeBufSubstringIterator(self)
+ redef fun substrings do return new RopeBufSubstringIterator(self)
# Builds an empty `RopeBuffer`
init do
end
private class RopeBufSubstringIterator
- super Iterator[String]
+ super Iterator[FlatText]
# Iterator on the substrings of the building string
- var iter: Iterator[String]
+ var iter: Iterator[FlatText]
# Makes a String out of the buffered part of the Ropebuffer
- var nsstr: String
+ var nsstr: FlatString
# Did we attain the buffered part ?
var nsstr_done = false
# Substrings of a Rope (i.e. Postfix iterator on leaves)
private class RopeSubstrings
- super IndexedIterator[String]
+ super IndexedIterator[FlatString]
# Visit Stack
var iter: RopeIterPiece is noinit
var max: Int is noinit
# Current leaf
- var str: String is noinit
+ var str: FlatString is noinit
init(root: RopeString) is old_style_init do
var r = new RopeIterPiece(root, true, false, null)
rnod = rnod.left
r = new RopeIterPiece(rnod, true, false, r)
else
- str = rnod
+ str = rnod.as(FlatString)
r.rdone = true
iter = r
break
r = new RopeIterPiece(rnod, true, false, r)
end
else
- str = rnod
+ str = rnod.as(FlatString)
r.rdone = true
iter = r
self.pos = pos - off
if not rnod isa Concat then
it.ldone = true
it.rdone = true
- str = rnod
+ str = rnod.as(FlatString)
iter = it.as(not null)
break
end
fun substring(from: Int, count: Int): SELFTYPE is abstract
# Iterates on the substrings of self if any
- fun substrings: Iterator[Text] is abstract
+ fun substrings: Iterator[FlatText] is abstract
# Is the current Text empty (== "")
#
# assert "helloworld".insert_at(" ", 5) == "hello world"
fun insert_at(s: String, pos: Int): SELFTYPE is abstract
- redef fun substrings: Iterator[String] is abstract
+ redef fun substrings is abstract
# Returns a reversed version of self
#