CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.util
Class SparseArray.Crawler

java.lang.Object
  extended by com.tangosol.util.SparseArray.Crawler
All Implemented Interfaces:
LongArray.Iterator, Cloneable, Iterator
Enclosing class:
SparseArray

protected class SparseArray.Crawler
extends Object
implements LongArray.Iterator, Cloneable

A red/black tree node iterator. The methods of this local class are not synchronized; the enclosing class is responsible for synchronization.

Author:
Cameron Purdy

Field Summary
protected static int ABOVE
           
protected  SparseArray.Node current
           
protected  int fromdir
           
protected static int LEFT
           
protected  SparseArray.Node NIL
          NIL is the sentinal Node that is used instead of null, simplifying the implementation of the red/black tree.
protected static int RIGHT
           
protected static int SITTING
           
 
Constructor Summary
protected SparseArray.Crawler(SparseArray.Node head)
          Crawler constructor.
protected SparseArray.Crawler(SparseArray.Node head, int fromdir)
          Crawler constructor.
 
Method Summary
 Object clone()
          Make a shallow copy of the node crawler.
 long getIndex()
          Returns the index of the current value, which is the value returned by the most recent call to the next method.
 Object getValue()
          Returns the current value, which is the same value returned by the most recent call to the next method, or the most recent value passed to setValue if setValue were called after the next method.
 boolean hasNext()
          Returns true if the iteration has more elements.
 Object next()
          Returns the next element in the iteration.
 void remove()
          Removes from the underlying collection the last element returned by the iterator (optional operation).
 Object setValue(Object oValue)
          Stores a new value at the current value index, returning the value that was replaced.
 String toString()
          Provide a string representation of this node's value.
 

Field Detail

ABOVE

protected static final int ABOVE
See Also:
Constant Field Values

LEFT

protected static final int LEFT
See Also:
Constant Field Values

SITTING

protected static final int SITTING
See Also:
Constant Field Values

RIGHT

protected static final int RIGHT
See Also:
Constant Field Values

current

protected SparseArray.Node current

fromdir

protected int fromdir

NIL

protected final transient SparseArray.Node NIL
NIL is the sentinal Node that is used instead of null, simplifying the implementation of the red/black tree.

Constructor Detail

SparseArray.Crawler

protected SparseArray.Crawler(SparseArray.Node head)
Crawler constructor.


SparseArray.Crawler

protected SparseArray.Crawler(SparseArray.Node head,
                              int fromdir)
Crawler constructor.

Method Detail

hasNext

public boolean hasNext()
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Specified by:
hasNext in interface LongArray.Iterator
Specified by:
hasNext in interface Iterator
Returns:
true if the iterator has more elements

next

public Object next()
Returns the next element in the iteration.

Specified by:
next in interface LongArray.Iterator
Specified by:
next in interface Iterator
Returns:
the next element in the iteration
Throws:
NoSuchElementException - iteration has no more elements

getIndex

public long getIndex()
Returns the index of the current value, which is the value returned by the most recent call to the next method.

Specified by:
getIndex in interface LongArray.Iterator
Throws:
IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method.

getValue

public Object getValue()
Returns the current value, which is the same value returned by the most recent call to the next method, or the most recent value passed to setValue if setValue were called after the next method.

Specified by:
getValue in interface LongArray.Iterator
Returns:
the current value
Throws:
IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method.

setValue

public Object setValue(Object oValue)
Stores a new value at the current value index, returning the value that was replaced. The index of the current value is obtainable by calling the getIndex method.

Specified by:
setValue in interface LongArray.Iterator
Returns:
the replaced value
Throws:
IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method.

remove

public void remove()
Removes from the underlying collection the last element returned by the iterator (optional operation). This method can be called only once per call to next. The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method.

Specified by:
remove in interface LongArray.Iterator
Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException - if the remove operation is not supported by this Iterator
IllegalStateException - if the next method has not yet been called, or the remove method has already been called after the last call to the next method.

toString

public String toString()
Provide a string representation of this node's value.


clone

public Object clone()
Make a shallow copy of the node crawler.


CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation