end
# Initializes a new Rope with a text embedded in directly
- init with_string(str: AbstractString) do
+ init with_string(str: String) do
self.parent_node = new ConcatNode
parent_node.as(ConcatNode).right_child = new LeafNode(str)
parent_node.as(ConcatNode).update_data
end
# Stores a flat version of self in cache
- private fun flatten: String
+ private fun flatten: FlatString
do
var native_final_str = calloc_string(length + 1)
var iter = new DFSRopeLeafIterator(self)
while iter.is_ok do
- iter.item.value._items.copy_to(native_final_str, iter.item.value.length, 0, offset)
+ iter.item.value.as(FlatString).items.copy_to(native_final_str, iter.item.value.length, 0, offset)
offset += iter.item.value.length
iter.next
end
# Compares the current Rope to another object (either another rope or a String)
redef fun == (other)
do
- if other == null or not (other isa Rope or other isa AbstractString) then return false
+ if other == null or not (other isa Rope or other isa FlatText) then return false
var self_iter = new RopeCharIterator(self)
if other isa Rope then
if self.length != other.length then return false
self_iter.next
other_iterator.next
end
- else if other isa AbstractString then
+ else if other isa FlatText then
var pos = 0
if self.length != other.length then return false
while self_iter.is_ok do
# Encapsulated string in the leaf node
private var _value: String
- init(val: AbstractString)
+ init(val: String)
do
self._value = val.to_s
self.length = val.length