diva.util
Class FilteredArrayIterator

java.lang.Object
  extended by diva.util.IteratorAdapter
      extended by diva.util.NullArrayIterator
          extended by diva.util.FilteredArrayIterator
All Implemented Interfaces:
java.util.Iterator

public abstract class FilteredArrayIterator
extends NullArrayIterator

An iterator over an array, in which elements are filtered by some function. To make this efficient, the filter is specified by overriding the accept() method in a subclass rather than by passing an instance of the Filter class. A null value (of the whole array) is treated as an empty array. This class can be subclassed to implement the remove() method. The method getLastIndex() return the index of the previously returned element.

Version:
$Id: FilteredArrayIterator.java 38798 2005-07-08 20:00:01Z cxh $
Author:
John Reekie

Field Summary
 
Fields inherited from class diva.util.NullArrayIterator
_array, _arraylen, _lastindex, _nextindex
 
Constructor Summary
FilteredArrayIterator(java.lang.Object[] array)
           
FilteredArrayIterator(java.lang.Object[] array, int length)
           
 
Method Summary
abstract  boolean accept(java.lang.Object o)
          Test if the object is acceptable for return by the iterator.
protected  void advance()
          Advance the next index to the next non-null element.
 
Methods inherited from class diva.util.NullArrayIterator
getLastIndex, hasNext, next
 
Methods inherited from class diva.util.IteratorAdapter
remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteredArrayIterator

public FilteredArrayIterator(java.lang.Object[] array)

FilteredArrayIterator

public FilteredArrayIterator(java.lang.Object[] array,
                             int length)
Method Detail

accept

public abstract boolean accept(java.lang.Object o)
Test if the object is acceptable for return by the iterator.


advance

protected void advance()
Advance the next index to the next non-null element. Set it to -1 if there are no more elements.

Overrides:
advance in class NullArrayIterator