org.openmdx.base.collection
Interface PopulationIterator

All Superinterfaces:
Iterator

public interface PopulationIterator
extends Iterator

Allows to iterate over a sparse array's population


Method Summary
 boolean hasNext()
          Returns true if this population iterator has more elements when traversing the sparse array in the forward direction.
 Object next()
          Returns the next element in the sparse array.
 int nextIndex()
          Returns the index of the element that would be returned by a subsequent call to next.
 void remove()
          Removes from the sparse array the last element that was returned by next (optional operation).
 void set(Object o)
          Replaces the last element returned by next or previous with the specified element (optional operation).
 

Method Detail

hasNext

boolean hasNext()
Returns true if this population iterator has more elements when traversing the sparse array in the forward direction. (In other words, returns true if next would return an element rather than throwing an exception.)

Specified by:
hasNext in interface Iterator
Returns:
true if the population iterator has more elements when traversing the sparse array in the forward direction.

next

Object next()
Returns the next element in the sparse array. This method may be called repeatedly to iterate through the sparse array.

Specified by:
next in interface Iterator
Returns:
the next element in the sparse array.
Throws:
NoSuchElementException - if the iteration has no next element.

nextIndex

int nextIndex()
Returns the index of the element that would be returned by a subsequent call to next. (Returns sparse array end if the population iterator is at the end of the sparse array.)

Returns:
the index of the element that would be returned by a subsequent call to next, or sparse array end if population iterator is at end of the sparse array.

remove

void remove()
Removes from the sparse array the last element that was returned by next (optional operation).

remove() is equivalent to set(null);.

Specified by:
remove in interface Iterator
Throws:
UnsupportedOperationException - if the remove operation is not supported by this population iterator.
IllegalStateException - if either nextIndex has been called or next has not been called.

set

void set(Object o)
Replaces the last element returned by next or previous with the specified element (optional operation).

Parameters:
o - the element with which to replace the last element returned by next.
Throws:
UnsupportedOperationException - if the set operation is not supported by this population iterator.
ClassCastException - if the class of the specified element prevents it from being added to this sparse array.
IllegalArgumentException - if some aspect of the specified element prevents it from being added to this sparse array.
IllegalStateException - if either nextIndex has been called or next has not been called.


This software is published under the BSD license. Copyright © 2003-2007, OMEX AG, Switzerland, All rights reserved. Use is subject to license terms.