jdsl.core.ref
Class ArrayObjectIterator

java.lang.Object
  |
  +--jdsl.core.ref.ArrayObjectIterator
All Implemented Interfaces:
ObjectIterator

public class ArrayObjectIterator
extends java.lang.Object
implements ObjectIterator

An array-based object iterator.

Version:
$Revision: 1.9 $, $Date: 2000/11/05 23:01:28 $
Author:
Ryan Shaun Baker (rsb)

Field Summary
protected  int iCurrentIndex_
           
protected  int iLastIndex_
           
 
Constructor Summary
ArrayObjectIterator(java.lang.Object[] array)
          Uses the array to store the elements that this iterator traverses.
ArrayObjectIterator(java.lang.Object[] array, int num)
          Traverses through the array, which is not copied, until num elements have been returned.
 
Method Summary
 boolean hasNext()
          Takes O(1) time
 java.lang.Object nextObject()
          Takes O(1) time
 java.lang.Object object()
          Takes O(1) time
 void reset()
          Takes O(1) time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iCurrentIndex_

protected int iCurrentIndex_

iLastIndex_

protected int iLastIndex_
Constructor Detail

ArrayObjectIterator

public ArrayObjectIterator(java.lang.Object[] array)
Uses the array to store the elements that this iterator traverses. The array is NOT copied. Takes O(N) time where N is the number of elements in the array.
Parameters:
array - The elements that this iterator should traverse.

ArrayObjectIterator

public ArrayObjectIterator(java.lang.Object[] array,
                           int num)
                    throws BoundaryViolationException
Traverses through the array, which is not copied, until num elements have been returned. Takes O(N) time where N is the number of elements in the array.
Method Detail

hasNext

public boolean hasNext()
Takes O(1) time
Specified by:
hasNext in interface ObjectIterator
Following copied from interface: jdsl.core.api.ObjectIterator
Returns:
Whether there is at least one object still unseen

nextObject

public java.lang.Object nextObject()
Takes O(1) time
Specified by:
nextObject in interface ObjectIterator
Following copied from interface: jdsl.core.api.ObjectIterator
Returns:
Next object to consider
Throws:
java.util.NoSuchElementException - if iterator has moved past the last object

object

public java.lang.Object object()
                        throws java.util.NoSuchElementException
Takes O(1) time
Specified by:
object in interface ObjectIterator
Following copied from interface: jdsl.core.api.ObjectIterator
Returns:
The object returned by the most recent next()
Throws:
java.util.NoSuchElementException - When the iterator is in its initial, before-the-first-object state

reset

public void reset()
Takes O(1) time
Specified by:
reset in interface ObjectIterator