Package com.tangosol.util
Class AbstractSparseArray.Crawler
java.lang.Object
com.tangosol.util.AbstractSparseArray.Crawler
- All Implemented Interfaces:
LongArray.Iterator<V>
,Cloneable
,Iterator<V>
- Direct Known Subclasses:
PrimitiveSparseArray.Iterator
- Enclosing class:
AbstractSparseArray<V>
protected class AbstractSparseArray.Crawler
extends Object
implements LongArray.Iterator<V>, Cloneable
A tree node iterator.
The methods of this local class are not synchronized; the enclosing class
is responsible for synchronization.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Crawler
(AbstractSparseArray.Node<V> head, int fromdir, boolean fForward) Crawler constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Make a shallow copy of the node crawler.protected AbstractSparseArray.Node
<V> Returns the current Node in the iteration.long
getIndex()
Returns the index of the current value, which is the value returned by the most recent call to the next method.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.next()
Returns the next element in the iteration.protected AbstractSparseArray.Node
<V> nextNode()
Returns the next Node in the iteration.void
remove()
Removes from the underlying collection the last element returned by the iterator (optional operation).Stores a new value at the current value index, returning the value that was replaced.toString()
Provide a string representation of this node's value.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
ABOVE
protected static final int ABOVE- See Also:
-
LEFT
protected static final int LEFT- See Also:
-
SITTING
protected static final int SITTING- See Also:
-
RIGHT
protected static final int RIGHT- See Also:
-
current
-
fromdir
protected int fromdir -
fForward
protected final boolean fForward
-
-
Constructor Details
-
Crawler
Crawler constructor.- Parameters:
head
- the node at which to start crawlingfromdir
- the direction in which to start crawlingfForward
- true iff crawler should advance forward towards the next element
-
-
Method Details
-
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.) -
next
Returns the next element in the iteration.- Specified by:
next
in interfaceIterator<V>
- Specified by:
next
in interfaceLongArray.Iterator<V>
- 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 interfaceLongArray.Iterator<V>
- Returns:
- the index of 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.
-
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 interfaceLongArray.Iterator<V>
- 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
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 interfaceLongArray.Iterator<V>
- Parameters:
oValue
- the new value to store- 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 interfaceIterator<V>
- Specified by:
remove
in interfaceLongArray.Iterator<V>
- Throws:
UnsupportedOperationException
- if the remove operation is not supported by this IteratorIllegalStateException
- 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
Provide a string representation of this node's value. -
clone
Make a shallow copy of the node crawler. -
nextNode
Returns the next Node in the iteration.- Returns:
- the next Node in the iteration
- Throws:
NoSuchElementException
- iteration has no more elements
-
currentNode
Returns the current Node in the iteration.- Returns:
- the current Node in the iteration
- 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.
-