core :: RopeSubstrings :: defaultinit
core :: RopeSubstrings :: max=
Maximum position inRope
(i.e. length - 1)
core $ RopeSubstrings :: SELF
Type of this instance, automatically specialized in every classcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: RopeSubstrings :: defaultinit
core :: Iterator :: defaultinit
core :: Object :: defaultinit
core :: IndexedIterator :: defaultinit
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: RopeSubstrings :: max=
Maximum position inRope
(i.e. length - 1)
core :: Object :: native_class_name
The class name of the object in CString format.Iterator
whose elements are sorted by the function
core :: Object :: output_class_name
Display class name on stdout (debug only).
# Substrings of a Rope (i.e. Postfix iterator on leaves)
private class RopeSubstrings
super IndexedIterator[FlatString]
# Visit Stack
var iter: RopeCharIteratorPiece is noinit
# Position in `Rope`
var pos: Int is noinit
# Maximum position in `Rope` (i.e. length - 1)
var max: Int is noinit
# Current leaf
var str: FlatString is noinit
init from(root: Concat, pos: Int) do
var r = new RopeCharIteratorPiece(root, true, false, null)
max = root.length - 1
var rnod: String = root
var off = pos
loop
if rnod isa Concat then
if off >= rnod._left.length then
r.rdone = true
off -= rnod._left.length
rnod = rnod._right
r = new RopeCharIteratorPiece(rnod, true, false, r)
else
rnod = rnod._left
r = new RopeCharIteratorPiece(rnod, true, false, r)
end
else
str = rnod.as(FlatString)
r.rdone = true
iter = r
self.pos = pos - off
break
end
end
end
redef fun item do return str
redef fun is_ok do return pos <= max
redef fun index do return pos
redef fun next do
pos += str.length
if pos > max then return
var it = iter.prev.as(not null)
var rnod = it.node
loop
if not rnod isa Concat then
it.ldone = true
it.rdone = true
str = rnod.as(FlatString)
iter = it
break
end
if not it.ldone then
rnod = rnod._left
it.ldone = true
it = new RopeCharIteratorPiece(rnod, false, false, it)
else if not it.rdone then
it.rdone = true
rnod = rnod._right
it = new RopeCharIteratorPiece(rnod, false, false, it)
else
it = it.prev.as(not null)
rnod = it.node
continue
end
end
end
end
lib/core/text/ropes.nit:566,1--640,3