+
+ # Two trees are equal if they have the same nodes in the same order
+ #
+ # ~~~
+ # var t1 = new OrderedTree[Int]
+ # t1.add_all(null, [1, 2])
+ # t1.add_all(1, [11, 12])
+ #
+ # var t2 = new OrderedTree[Int]
+ # t2.add_all(null, [1, 2])
+ #
+ # assert t1 != t2
+ #
+ # t2.add_all(1, [11, 12])
+ #
+ # assert t1 == t2
+ # ~~~
+ redef fun ==(other)
+ do
+ if not other isa OrderedTree[Object] then return false
+ return roots == other.roots and sub == other.sub
+ end
+
+ redef fun hash
+ do
+ return roots.hash + sub.hash
+ end
+
+ # Shallow clone of the tree.
+ #
+ # ~~~
+ # var t = new OrderedTree[Int]
+ # t.add_all(null, [1, 2])
+ # t.add_all(1, [11, 12])
+ #
+ # assert t.clone == t
+ # ~~~
+ redef fun clone
+ do
+ var res = new OrderedTree[E]
+ res.add_all(null, roots)
+ for p, es in sub do
+ res.add_all(p, es)
+ end
+ return res
+ end