src/java/org/apache/cassandra/utils/MerkleTree.java
/**
         * Find the next TreeRange.
         *
         * @return The next TreeRange.
         */
Find the next TreeRange.
@return The next TreeRange.
Find the next TreeRange . @return The next TreeRange .
public TreeRange computeNext()
        {
            while (!tovisit.isEmpty())
            {
                TreeRange active = tovisit.pop();
                if (active.hashable instanceof Leaf)
                {
                    if (active.isWrapAround() && !tovisit.isEmpty())
                        tovisit.addLast(active);
                    return active;
                }
                Inner node = (Inner)active.hashable;
                TreeRange left = new TreeRange(tree, active.left, node.token, inc(active.depth), node.lchild);
                TreeRange right = new TreeRange(tree, node.token, active.right, inc(active.depth), node.rchild);
                if (right.isWrapAround())
                {
                    tovisit.addLast(left);
                    tovisit.addFirst(right);
                }
                else
                {
                    tovisit.addFirst(right);
                    tovisit.addFirst(left);
                }
            }
            return endOfData();
        }
public TreeRange computeNext ( ) { while ( ! tovisit . isEmpty ( ) ) { TreeRange active = tovisit . pop ( ) ; if ( active . hashable instanceof Leaf ) { if ( active . isWrapAround ( ) && ! tovisit . isEmpty ( ) ) tovisit . addLast ( active ) ; return active ; } Inner node = ( Inner ) active . hashable ; TreeRange left = new TreeRange ( tree , active . left , node . token , inc ( active . depth ) , node . lchild ) ; TreeRange right = new TreeRange ( tree , node . token , active . right , inc ( active . depth ) , node . rchild ) ; if ( right . isWrapAround ( ) ) { tovisit . addLast ( left ) ; tovisit . addFirst ( right ) ; } else { tovisit . addFirst ( right ) ; tovisit . addFirst ( left ) ; } } return endOfData ( ) ; }
Find the next TreeRange.
Find the next TreeRange .
// found a leaf invalid range // put to be taken again last // whatever is on the left is 'after' everything we have seen so far (it has greater tokens) // do left first then right