nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d78d6a5
)
lib/standard/ropes: Added constructors for a Rope
author
Lucas Bajolet
<r4pass@hotmail.com>
Wed, 4 Jun 2014 20:39:12 +0000
(16:39 -0400)
committer
Lucas Bajolet
<r4pass@hotmail.com>
Wed, 4 Jun 2014 20:39:12 +0000
(16:39 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
lib/standard/ropes.nit
patch
|
blob
|
history
diff --git
a/lib/standard/ropes.nit
b/lib/standard/ropes.nit
index
fc74932
..
eef9360
100644
(file)
--- a/
lib/standard/ropes.nit
+++ b/
lib/standard/ropes.nit
@@
-73,6
+73,19
@@
abstract class Rope
# Root node, entry point of a Rope.
private var root: RopeNode
+ # Empty Rope
+ init do from("")
+
+ # Creates a new Rope with `s` as root
+ init from(s: String) do
+ if s isa RopeString then root = s.root else root = new Leaf(s.as(FlatString))
+ end
+
+ private init from_root(r: RopeNode)
+ do
+ root = r
+ end
+
redef fun length do return root.length
end