nz.ac.waikato.jdsl.core.ref
Class ArrayObjectIterator

java.lang.Object
  extended by nz.ac.waikato.jdsl.core.ref.ArrayObjectIterator
All Implemented Interfaces:
ObjectIterator

public class ArrayObjectIterator
extends java.lang.Object
implements ObjectIterator

An array-based object iterator.

Version:
JDSL 2.1.1
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.

Throws:
BoundaryViolationException
Method Detail

hasNext

public boolean hasNext()
Takes O(1) time

Specified by:
hasNext in interface 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
Returns:
Next object to consider

object

public java.lang.Object object()
                        throws java.util.NoSuchElementException
Takes O(1) time

Specified by:
object in interface 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


Copyright © 2009 ModelJUnit Project. All Rights Reserved.