/** * Write this node out as a String, using the specified colors to write * each of the node values. */ String toString(List colors) { StringBuffer result = new StringBuffer(); asTree(0, result, colors); return result.toString(); } /**
public T0 value() { if(node == null) throw new IllegalStateException(); return node.get(); } public Element<T0> node() {
byte subtreeRootRightHeight = subtreeRoot.right != null ? subtreeRoot.right.height : 0; subtreeRoot.height = (byte)(Math.max(subtreeRootLeftHeight, subtreeRootRightHeight) + 1); subtreeRoot.refreshCounts(!zeroQueue.contains(subtreeRoot)); byte newSubtreeRootRightHeight = newSubtreeRoot.right != null ? newSubtreeRoot.right.height : 0; newSubtreeRoot.height = (byte)(Math.max(newSubtreeRootLeftHeight, newSubtreeRootRightHeight) + 1); newSubtreeRoot.refreshCounts(!zeroQueue.contains(newSubtreeRoot));
/** * 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; } }
/** * Print this tree as a list of values. */ @Override public String toString() { if(root == null) return ""; return root.toString( ); }
/** * 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; } }
/** * Print this tree as a list of values. */ @Override public String toString() { if(root == null) return ""; return root.toString( ); }
/** * 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; } }
byte subtreeRootRightHeight = subtreeRoot.right != null ? subtreeRoot.right.height : 0; subtreeRoot.height = (byte)(Math.max(subtreeRootLeftHeight, subtreeRootRightHeight) + 1); subtreeRoot.refreshCounts(!zeroQueue.contains(subtreeRoot)); byte newSubtreeRootRightHeight = newSubtreeRoot.right != null ? newSubtreeRoot.right.height : 0; newSubtreeRoot.height = (byte)(Math.max(newSubtreeRootLeftHeight, newSubtreeRootRightHeight) + 1); newSubtreeRoot.refreshCounts(!zeroQueue.contains(newSubtreeRoot));
public T0 value() { if(node == null) throw new IllegalStateException(); return node.get(); } public Element<T0> node() {
/** * Write this node out as a String, using the specified colors to write * each of the node values. */ String toString(List colors) { StringBuffer result = new StringBuffer(); asTree(0, result, colors); return result.toString(); } /**
/** * Print this tree as a list of values. */ @Override public String toString() { if(root == null) return ""; return root.toString( ); }
SimpleNode < T0> inserted = new SimpleNode < T0> ( size, value, parent); parent.left = inserted; fixCountsThruRoot(parent, size); SimpleNode < T0> inserted = new SimpleNode < T0> ( size, value, parent); parent.right = inserted; fixCountsThruRoot(parent, size);
byte subtreeRootRightHeight = subtreeRoot.right != null ? subtreeRoot.right.height : 0; subtreeRoot.height = (byte)(Math.max(subtreeRootLeftHeight, subtreeRootRightHeight) + 1); subtreeRoot.refreshCounts(!zeroQueue.contains(subtreeRoot)); byte newSubtreeRootRightHeight = newSubtreeRoot.right != null ? newSubtreeRoot.right.height : 0; newSubtreeRoot.height = (byte)(Math.max(newSubtreeRootLeftHeight, newSubtreeRootRightHeight) + 1); newSubtreeRoot.refreshCounts(!zeroQueue.contains(newSubtreeRoot));
public T0 value() { if(node == null) throw new IllegalStateException(); return node.get(); } public Element<T0> node() {
/** * Write this node out as a String, using the specified colors to write * each of the node values. */ String toString(List colors) { StringBuffer result = new StringBuffer(); asTree(0, result, colors); return result.toString(); } /**
/** {@inheritDoc} */ @Override public String toString() { return toString(Arrays.asList(new String[] { "A", "B", "C", "D", "E", "F", "G", "H"})); }
if(index != 0) throw new IndexOutOfBoundsException(); this.root = new SimpleNode < T0> ( size, value, null); assert(valid()); return this.root;
byte subtreeRootRightHeight = subtreeRoot.right != null ? subtreeRoot.right.height : 0; subtreeRoot.height = (byte)(Math.max(subtreeRootLeftHeight, subtreeRootRightHeight) + 1); subtreeRoot.refreshCounts(!zeroQueue.contains(subtreeRoot)); byte newSubtreeRootRightHeight = newSubtreeRoot.right != null ? newSubtreeRoot.right.height : 0; newSubtreeRoot.height = (byte)(Math.max(newSubtreeRootLeftHeight, newSubtreeRootRightHeight) + 1); newSubtreeRoot.refreshCounts(!zeroQueue.contains(newSubtreeRoot));
int comparison = comparator.compare(element, node.get());