public static interface BinaryTreeNode.CachingIterator<N extends BinaryTreeNode<E>,E,C> extends Iterator<N>
Modifier and Type | Method and Description |
---|---|
boolean |
cacheWithLowerSubNode(C object)
After
Iterator.next() has returned a node,
calling this method caches the provided object with the lower sub-node so that it can
be retrieved with getCached() when the lower sub-node is visited later. |
boolean |
cacheWithUpperSubNode(C object)
After
Iterator.next() has returned a node,
calling this method caches the provided object with the upper sub-node so that it can
be retrieved with getCached() when the upper sub-node is visited later. |
C |
getCached()
After
Iterator.next() has returned a node,
if an object was cached by a call to cacheWithLowerSubNode(Object) or cacheWithUpperSubNode(Object)
was called when that node's parent was previously returned by Iterator.next() ,
then this returns that cached object. |
forEachRemaining, hasNext, next, remove
C getCached()
Iterator.next()
has returned a node,
if an object was cached by a call to cacheWithLowerSubNode(Object)
or cacheWithUpperSubNode(Object)
was called when that node's parent was previously returned by Iterator.next()
,
then this returns that cached object.boolean cacheWithLowerSubNode(C object)
Iterator.next()
has returned a node,
calling this method caches the provided object with the lower sub-node so that it can
be retrieved with getCached()
when the lower sub-node is visited later.
Returns false if it could not be cached, either because the node has since been removed with a call to Iterator.remove()
,
because Iterator.next()
has not been called yet, or because there is no lower sub node for the node previously returned by Iterator.next()
.
The caching and retrieval is done in constant time.
object
- the object to be retrieved later.boolean cacheWithUpperSubNode(C object)
Iterator.next()
has returned a node,
calling this method caches the provided object with the upper sub-node so that it can
be retrieved with getCached()
when the upper sub-node is visited later.
Returns false if it could not be cached, either because the node has since been removed with a call to Iterator.remove()
,
because Iterator.next()
has not been called yet, or because there is no upper sub node for the node previously returned by Iterator.next()
.
The caching and retrieval is done in constant time.
object
- the object to be retrieved later.