Package diva.util

Class 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$
    Author:
    John Reekie
    • Constructor Summary

      Constructors 
      Constructor Description
      FilteredArrayIterator​(java.lang.Object[] array)
      Construct a filtered array iterator.
      FilteredArrayIterator​(java.lang.Object[] array, int length)
      Construct a filtered array iterator.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • FilteredArrayIterator

        public FilteredArrayIterator​(java.lang.Object[] array)
        Construct a filtered array iterator.
        Parameters:
        array - The array
      • FilteredArrayIterator

        public FilteredArrayIterator​(java.lang.Object[] array,
                                     int length)
        Construct a filtered array iterator.
        Parameters:
        array - The array
        length - The length
    • Method Detail

      • accept

        public abstract boolean accept​(java.lang.Object o)
        Test if the object is acceptable for return by the iterator.
        Parameters:
        o - The object to be tested
        Returns:
        True if the object is acceptable
      • 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