/** * Remove the specified element from the tree outright. */ public void remove(Element<T0> element) { SimpleNode < T0> node = ( SimpleNode < T0> )element; assert(root != null); // delete the node by adding to the zero queue fixCountsThruRoot(node, -1 ); zeroQueue.add(node); drainZeroQueue(); assert(valid()); }
/** * Remove the specified element from the tree outright. */ public void remove(Element<T0> element) { SimpleNode < T0> node = ( SimpleNode < T0> )element; assert(root != null); // delete the node by adding to the zero queue fixCountsThruRoot(node, -1 ); zeroQueue.add(node); drainZeroQueue(); assert(valid()); }
/** * 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; } }
/** * Remove the specified element from the tree outright. */ public void remove(Element<T0> element) { SimpleNode < T0> node = ( SimpleNode < T0> )element; assert(root != null); // delete the node by adding to the zero queue fixCountsThruRoot(node, -1 ); zeroQueue.add(node); drainZeroQueue(); assert(valid()); }
/** * 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; } }
/** * Remove size values at the specified index. Only values of the type * specified in indexColors will be removed. * * <p>Note that if the two nodes on either side of the removed node could * be merged, they probably will not be merged by this implementation. This * is to simplify the implementation, but it means that when iterating a * tree, sometimes multiple nodes of the same color and value will be * encountered in sequence. */ public void remove(int index, int size) { if(size == 0) return; assert(index >= 0); assert(index + size <= size( )); assert(root != null); // remove values from the tree removeFromSubtree(root, index, size); // clean up any nodes that got deleted drainZeroQueue(); assert(valid()); }
/** * Remove size values at the specified index. Only values of the type * specified in indexColors will be removed. * * <p>Note that if the two nodes on either side of the removed node could * be merged, they probably will not be merged by this implementation. This * is to simplify the implementation, but it means that when iterating a * tree, sometimes multiple nodes of the same color and value will be * encountered in sequence. */ public void remove(int index, int size) { if(size == 0) return; assert(index >= 0); assert(index + size <= size( )); assert(root != null); // remove values from the tree removeFromSubtree(root, index, size); // clean up any nodes that got deleted drainZeroQueue(); assert(valid()); }
/** * Remove size values at the specified index. Only values of the type * specified in indexColors will be removed. * * <p>Note that if the two nodes on either side of the removed node could * be merged, they probably will not be merged by this implementation. This * is to simplify the implementation, but it means that when iterating a * tree, sometimes multiple nodes of the same color and value will be * encountered in sequence. */ public void remove(int index, int size) { if(size == 0) return; assert(index >= 0); assert(index + size <= size( )); assert(root != null); // remove values from the tree removeFromSubtree(root, index, size); // clean up any nodes that got deleted drainZeroQueue(); assert(valid()); }