com.sosnoski.util
Class WrappedArrayIterator

java.lang.Object
  |
  +--com.sosnoski.util.WrappedArrayIterator
All Implemented Interfaces:
java.util.Iterator

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

Iterator class for values contained in a possibly wrapped array range. This type of iterator can be used for items in an object array which are contiguous.modulo the array size.

Version:
1.1
Author:
Dennis M. Sosnoski

Field Summary
protected  java.lang.Object[] m_array
          Array supplying values for iteration.
protected  int m_last
          Ending offset for values.
protected  int m_offset
          Offset of next iteration value.
 
Method Summary
static java.util.Iterator buildIterator(java.lang.Object[] array, int start, int end)
          Build iterator.
 boolean hasNext()
          Check for iteration element available.
 java.lang.Object next()
          Get next iteration element.
 void remove()
          Remove element from iteration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_array

protected java.lang.Object[] m_array
Array supplying values for iteration.

m_offset

protected int m_offset
Offset of next iteration value.

m_last

protected int m_last
Ending offset for values.
Method Detail

hasNext

public boolean hasNext()
Check for iteration element available.
Specified by:
hasNext in interface java.util.Iterator
Returns:
true if element available, false if not

next

public java.lang.Object next()
Get next iteration element.
Specified by:
next in interface java.util.Iterator
Returns:
next iteration element
Throws:
java.util.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:
remove in interface java.util.Iterator
Throws:
UnsupportedOperationException - for unsupported operation

buildIterator

public static java.util.Iterator buildIterator(java.lang.Object[] array,
                                               int start,
                                               int end)
Build iterator.
Parameters:
array - array containing values to be iterated (may be null)
start - offset of first value in array
end - offset of last value in array (the same as start offset, if the array is empty)
Returns:
constructed iterator


Company Web Site

XML Benchmark Home