Add a new element e in the tree.

p is the parent of e. If p is null, then e is a root element.

If e is already in the tree, it is detached from its old parent and attached to the new parent p.

Property definitions

ordered_tree $ OrderedTree :: add
	# Add a new element `e` in the tree.
	#
	# `p` is the parent of `e`.
	# If `p` is null, then `e` is a root element.
	#
	# If `e` is already in the tree, it is detached from its old
	# parent and attached to the new parent `p`.
	fun add(p: nullable E, e: E)
	do
		detach(e)
		parents[e] = p
		if p == null then
			roots.add(e)
		else
			if not has(p) then add(null, p)
			if sub.has_key(p) then
				sub[p].add(e)
			else
				sub[p] = [e]
			end
		end
	end
lib/ordered_tree/ordered_tree.nit:94,2--115,4