/** {@inheritDoc} */ public Element<T0> next() { return SimpleTree.next(this); }
/** {@inheritDoc} */ @Override public Element<T0> next() { return SimpleTree.next(this); }
/** {@inheritDoc} */ public Element<T0> next() { return SimpleTree.next(this); }
for( SimpleNode < T0> node = firstNode(); node != null; node = next(node)) {
for( SimpleNode < T0> node = firstNode(); node != null; node = next(node)) {
/** * @return true if this tree is structurally valid */ private boolean valid() { // walk through all nodes in the tree, looking for something invalid for( SimpleNode < T0> node = firstNode(); node != null; node = next(node)) { // sizes (counts) are valid int originalCount1 = node.count1; node.refreshCounts(!zeroQueue.contains(node)); assert(originalCount1 == node.count1) : "Incorrect count 0 on node: \n" + node + "\n Expected " + node.count1 + " but was " + originalCount1; // heights are valid int leftHeight = node.left != null ? node.left.height : 0; int rightHeight = node.right != null ? node.right.height : 0; assert(Math.max(leftHeight, rightHeight) + 1 == node.height); // left child's parent is this assert(node.left == null || node.left.parent == node); // right child's parent is this assert(node.right == null || node.right.parent == node); // tree is AVL assert(Math.abs(leftHeight - rightHeight) < 2) : "Subtree is not AVL: \n" + node; } // we're valid return true; }
/** * Step to the next node. */ public void nextNode( ) { if(!hasNextNode( )) { throw new NoSuchElementException(); } // start at the first node in the tree if(node == null) { node = tree.firstNode(); index = 0; return; } // scan through the nodes, looking for the first one of the right color while(true) { count1 += 1 - index; node = SimpleTree.next(node); index = 0; // we've found a node that meet our requirements, so return break; } }
/** * Step to the next node. */ public void nextNode( ) { if(!hasNextNode( )) { throw new NoSuchElementException(); } // start at the first node in the tree if(node == null) { node = tree.firstNode(); index = 0; return; } // scan through the nodes, looking for the first one of the right color while(true) { count1 += 1 - index; node = SimpleTree.next(node); index = 0; // we've found a node that meet our requirements, so return break; } }
/** * Step to the next node. */ public void nextNode( ) { if(!hasNextNode( )) { throw new NoSuchElementException(); } // start at the first node in the tree if(node == null) { node = tree.firstNode(); index = 0; return; } // scan through the nodes, looking for the first one of the right color while(true) { count1 += 1 - index; node = SimpleTree.next(node); index = 0; // we've found a node that meet our requirements, so return break; } }
node = SimpleTree.next(node); index = 0;
node = SimpleTree.next(node); index = 0;
/** * Step to the next element. */ public void next( ) { if(!hasNext( )) { throw new NoSuchElementException(); } // start at the first node in the tree if(node == null) { node = tree.firstNode(); index = 0; return; // increment within the current node } else if( index < 1 - 1) { count1++; index++; return; } // scan through the nodes, looking for the first one of the right color while(true) { count1 += 1 - index; node = SimpleTree.next(node); index = 0; // we've found a node that meet our requirements, so return break; } }
for( SimpleNode < T0> currentFollower = parent; true; currentFollower = next(currentFollower)) {
for( SimpleNode < T0> currentFollower = parent; true; currentFollower = next(currentFollower)) {
for( SimpleNode < T0> currentFollower = parent; true; currentFollower = next(currentFollower)) {