protected class TreeList.TreeItr extends Object implements TreeIterator
| Constructor and Description |
|---|
TreeItr(int i) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Node o) |
int |
currentDepth()
Depth of the last node fetched with next() or nextNode()
|
protected Node |
getNextLeafNode()
Simply returns the 'smallest' of all available nodes (compared to the 'previous node')
This is actually an alternavite implementation for getNextNode, but it also works when
'leaf' constraints are applied.
|
protected Node |
getNextNode()
Implementation idea graphicly.
|
Node |
getParent()
Returns the 'parent' node of the most recently returned Node.
|
protected Node |
getRealNode(int index)
Returns the 'real' node, thus the just used 'next' node of index.
|
NodeList |
getSiblings()
Returns all nodes with the same parent as the most recently return Node (include that node
itself).
|
boolean |
hasNext() |
boolean |
hasPrevious() |
Node |
next() |
int |
nextIndex() |
Node |
nextNode()
Returns the next element in the iterator as a Node
|
protected boolean |
prepare(int index)
Makes sure that query with given index has an iterator, a 'next' node and a 'previous' node.
|
Node |
previous() |
int |
previousIndex() |
Node |
previousNode()
Returns the previous element in the iterator as a Node
|
void |
remove() |
void |
set(Node o) |
protected void |
useNext(int index)
Uses the new 'next' node of the iterator with the given index.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic boolean hasNext()
protected final boolean prepare(int index)
protected final void useNext(int index)
protected final Node getRealNode(int index)
public Node nextNode()
NodeIteratornextNode in interface NodeIteratorpublic Node getParent()
TreeIteratornull if there
is no such node.getParent in interface TreeIteratorpublic NodeList getSiblings()
TreeIteratorgetSiblings in interface TreeIteratorpublic int currentDepth()
currentDepth in interface TreeIteratorpublic Node next()
protected final Node getNextNode()
iterators
current-2 current-1 current current+1 [///]: used node
[///] [///] [///] [///] [|||]: last used node (lastNode)
[ ]: unused node
... [///] [///] [|||] _ [///] previousNodes [ * ]: considered next node (nextListNextNode)
\
[ ] [ ] [ ] `---> [ * ] nextNodes
if (! [|||] contained by [ * ]) current--
Every time next is called, the last used node is compared with the next node of the
next iterator (the arrow in the above scheme). If the last used node is 'contained' by
this next node, then this next node of the next iterator will be 'next()' otherwise current
is decreased by one and next is called recursively. This means that the next node is always
one longer than the current one, equally long, or shorter.
If 'leaf constraints' are in use, then the implementation jumps to getNextLeafNode, which simply returns the 'smallest node' of all iterators.protected final Node getNextLeafNode()
public boolean hasPrevious()
hasPrevious in interface ListIterator<Node>public Node previousNode()
NodeIteratorpreviousNode in interface NodeIteratorpublic Node previous()
previous in interface ListIterator<Node>public int nextIndex()
nextIndex in interface ListIterator<Node>public int previousIndex()
previousIndex in interface ListIterator<Node>public void remove()
public void set(Node o)
set in interface ListIterator<Node>public void add(Node o)
add in interface ListIterator<Node>MMBase 1.9-SNAPSHOT - ${javadoctimestamp}