Interface BinaryTreeNode.CachingIterator<N extends BinaryTreeNode<E>, E, C>
- All Superinterfaces:
Iterator<N>
- Enclosing class:
BinaryTreeNode<E>
public static interface BinaryTreeNode.CachingIterator<N extends BinaryTreeNode<E>, E, C>
extends Iterator<N>
- Author:
- scfoley
-
Method Summary
Modifier and TypeMethodDescriptionbooleancacheWithLowerSubNode(C object) AfterIterator.next()has returned a node, calling this method caches the provided object with the lower sub-node so that it can be retrieved withgetCached()when the lower sub-node is visited later.booleancacheWithUpperSubNode(C object) AfterIterator.next()has returned a node, calling this method caches the provided object with the upper sub-node so that it can be retrieved withgetCached()when the upper sub-node is visited later.AfterIterator.next()has returned a node, if an object was cached by a call tocacheWithLowerSubNode(Object)orcacheWithUpperSubNode(Object)was called when that node's parent was previously returned byIterator.next(), then this returns that cached object.Methods inherited from interface Iterator
forEachRemaining, hasNext, next, remove
-
Method Details
-
getCached
C getCached()AfterIterator.next()has returned a node, if an object was cached by a call tocacheWithLowerSubNode(Object)orcacheWithUpperSubNode(Object)was called when that node's parent was previously returned byIterator.next(), then this returns that cached object.- Returns:
- the cached object
-
cacheWithLowerSubNode
AfterIterator.next()has returned a node, calling this method caches the provided object with the lower sub-node so that it can be retrieved withgetCached()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(), becauseIterator.next()has not been called yet, or because there is no lower sub node for the node previously returned byIterator.next().The caching and retrieval is done in constant time.
- Parameters:
object- the object to be retrieved later.
-
cacheWithUpperSubNode
AfterIterator.next()has returned a node, calling this method caches the provided object with the upper sub-node so that it can be retrieved withgetCached()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(), becauseIterator.next()has not been called yet, or because there is no upper sub node for the node previously returned byIterator.next().The caching and retrieval is done in constant time.
- Parameters:
object- the object to be retrieved later.- Returns:
-