Package org.jibx.util
Class SparseArrayIterator
java.lang.Object
org.jibx.util.SparseArrayIterator
- All Implemented Interfaces:
Iterator
Iterator class for sparse values in an array. This type of iterator
can be used for an object array which has references interspersed with
nulls.- Author:
- Dennis M. Sosnoski
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SparseArrayIteratorEmpty iterator.private Object[]Array supplying values for iteration.private intOffset of next iteration value. -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
EMPTY_ITERATOR
Empty iterator. -
m_array
Array supplying values for iteration. -
m_offset
private int m_offsetOffset of next iteration value.
-
-
Constructor Details
-
SparseArrayIterator
Internal constructor.- Parameters:
array- array containing values to be iterated
-
-
Method Details
-
advance
protected boolean advance()Advance to next iteration value. This advances the current position in the array to the next non-nullvalue.- Returns:
trueif element available,falseif not
-
hasNext
public boolean hasNext()Check for iteration element available. -
next
Get next iteration element.- Specified by:
nextin interfaceIterator- Returns:
- next iteration element
- Throws:
NoSuchElementException- if past end of iteration
-
remove
public void remove()Remove element from iteration. This optional operation is not supported and always throws an exception.- Specified by:
removein interfaceIterator- Throws:
UnsupportedOperationException- for unsupported operation
-
buildIterator
Build iterator.- Parameters:
array- array containing values to be iterated (may benull)- Returns:
- constructed iterator
-