textmaven.tst
Class TSTIterator

java.lang.Object
  extended bytextmaven.tst.TSTIterator
All Implemented Interfaces:
java.util.Iterator
Direct Known Subclasses:
TSTCountIterator

public class TSTIterator
extends java.lang.Object
implements java.util.Iterator

Read only iterator for TST.

Author:
Peter Kolloch

Field Summary
protected static int[] REL_TO_STATE
          Conversion array from node relative constants to states.
protected static int[] STATE_TO_REL
          Converstion from states to node relative constants.
static int STATE0_LO
          Inspect child with lower key next
static int STATE1_NODE
          Inspect current node next
static int STATE2_EQ
          Inspect child with equal, but longer key next
static int STATE3_HI
          Inspect child with higher key next
static int STATE4_DONE
          Move back to parent
 
Constructor Summary
TSTIterator(textmaven.tst.TSTNode root)
          Constructs an iterator traversing the tree with the given root node.
 
Method Summary
protected  void calculateNext(int state)
          Starts looking for a plausible next node at the current node with the given state.
 boolean hasNext()
           
 java.lang.Object next()
           
 TSTEntry nextEntry()
          As next, but with the concrete rather than the abstract return type.
 void remove()
          NOT SUPPORTED!
protected  boolean visitNode(textmaven.tst.TSTNode node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE0_LO

public static final int STATE0_LO
Inspect child with lower key next

See Also:
Constant Field Values

STATE1_NODE

public static final int STATE1_NODE
Inspect current node next

See Also:
Constant Field Values

STATE2_EQ

public static final int STATE2_EQ
Inspect child with equal, but longer key next

See Also:
Constant Field Values

STATE3_HI

public static final int STATE3_HI
Inspect child with higher key next

See Also:
Constant Field Values

STATE4_DONE

public static final int STATE4_DONE
Move back to parent

See Also:
Constant Field Values

REL_TO_STATE

protected static final int[] REL_TO_STATE
Conversion array from node relative constants to states.


STATE_TO_REL

protected static final int[] STATE_TO_REL
Converstion from states to node relative constants.

Constructor Detail

TSTIterator

public TSTIterator(textmaven.tst.TSTNode root)
Constructs an iterator traversing the tree with the given root node. The returned keys are relative to the given root.

Parameters:
root - the root of the traversed sub tree (not tested for anything but the root node)
Method Detail

remove

public void remove()
NOT SUPPORTED!

Specified by:
remove in interface java.util.Iterator

visitNode

protected boolean visitNode(textmaven.tst.TSTNode node)

calculateNext

protected void calculateNext(int state)
Starts looking for a plausible next node at the current node with the given state. The states are explained in the doc of the state constants. The result is stored in the nextNode instance variable. If nextNode != null nothing is done.

See Also:
STATE0_LO, STATE1_NODE, STATE2_EQ, STATE3_HI, STATE4_DONE

hasNext

public boolean hasNext()
Specified by:
hasNext in interface java.util.Iterator
See Also:
Iterator.hasNext()

next

public java.lang.Object next()
Specified by:
next in interface java.util.Iterator
See Also:
Iterator.next()

nextEntry

public TSTEntry nextEntry()
As next, but with the concrete rather than the abstract return type.



Copyright © 2002-2005 Sourceforge. All Rights Reserved.