/** * Add a tree node in sorted order. * * @param size the size of the node to insert. * @param value the node value. If non-<code>null</code>, the node may be * combined with other nodes of the same color and value. <code>null</code> * valued nodes will never be combined with each other. * @return the element the specified value was inserted into. This is non-null * unless the size parameter is 0, in which case the result is always * <code>null</code>. */ public Element<T0> addInSortedOrder(byte color, T0 value, int size) { assert(size >= 0); if(this.root == null) { this.root = new SimpleNode < T0> ( size, value, null); assert(valid()); return this.root; } else { SimpleNode < T0> inserted = insertIntoSubtreeInSortedOrder(root, value, size); assert(valid()); return inserted; } }
/** * Add a tree node in sorted order. * * @param size the size of the node to insert. * @param value the node value. If non-<code>null</code>, the node may be * combined with other nodes of the same color and value. <code>null</code> * valued nodes will never be combined with each other. * @return the element the specified value was inserted into. This is non-null * unless the size parameter is 0, in which case the result is always * <code>null</code>. */ public Element<T0> addInSortedOrder(byte color, T0 value, int size) { assert(size >= 0); if(this.root == null) { this.root = new SimpleNode < T0> ( size, value, null); assert(valid()); return this.root; } else { SimpleNode < T0> inserted = insertIntoSubtreeInSortedOrder(root, value, size); assert(valid()); return inserted; } }
/** * Add a tree node in sorted order. * * @param size the size of the node to insert. * @param value the node value. If non-<code>null</code>, the node may be * combined with other nodes of the same color and value. <code>null</code> * valued nodes will never be combined with each other. * @return the element the specified value was inserted into. This is non-null * unless the size parameter is 0, in which case the result is always * <code>null</code>. */ public Element<T0> addInSortedOrder(byte color, T0 value, int size) { assert(size >= 0); if(this.root == null) { this.root = new SimpleNode < T0> ( size, value, null); assert(valid()); return this.root; } else { SimpleNode < T0> inserted = insertIntoSubtreeInSortedOrder(root, value, size); assert(valid()); return inserted; } }