# A reverse iterator capable of working with `Rope` objects
private class RopeCharReverseIterator
super IndexedIterator[Char]
# Current CString
var ns: String is noautoinit
# Current position in CString
var pns: Int is noautoinit
# Position in the Rope (0-indexed)
var pos: Int is noautoinit
# Iterator on the substrings, does the Postfix part of
# the Rope traversal.
var subs: IndexedIterator[String] is noautoinit
init from(root: Concat, pos: Int) do
self.pos = pos
subs = new ReverseRopeSubstrings.from(root, pos)
ns = subs.item
pns = pos - subs.index
end
redef fun index do return pos
redef fun is_ok do return pos >= 0
redef fun item do return ns[pns]
redef fun next do
pns -= 1
pos -= 1
if pns >= 0 then return
if not subs.is_ok then return
subs.next
if not subs.is_ok then return
ns = subs.item
pns = ns.length - 1
end
end
lib/core/text/ropes.nit:415,1--452,3