// add puts the node v into the tree. The node must not be part of the
// tree before.
add puts the node v into the tree. The node must not be part of the
tree before.
// add puts the node v into the tree . The node must not be part of the // tree before .
func (t *binTree) add(v uint32) {
	vn := &t.node[v]
	vn.l, vn.r = null, null
	if t.root == null {
		t.root = v
		vn.p = null
		return
	}
	x := vn.x
	p := t.root
	for {
		pn := &t.node[p]
		if x <= pn.x {
			if pn.l == null {
				pn.l = v
				vn.p = p
				return
			}
			p = pn.l
		} else {
			if pn.r == null {
				pn.r = v
				vn.p = p
				return
			}
			p = pn.r
		}
	}
}
func ( t * binTree ) add ( v uint32 ) { vn := & t . node [ v ] vn . l , vn . r = null , null if t . root == null { t . root = v vn . p = null return } x := vn . x p := t . root for { pn := & t . node [ p ] if x <= pn . x { if pn . l == null { pn . l = v vn . p = p return } p = pn . l } else { if pn . r == null { pn . r = v vn . p = p return } p = pn . r } } }
add puts the node v into the tree.
add puts the node v into the tree .
// Set left and right to null indices. // If the binary tree is empty make v the root. // Search for the right leave link and add the new node.