PCJ API
Version 1.2

bak.pcj.adapter
Class IteratorToDoubleIteratorAdapter

java.lang.Object
  extended bybak.pcj.adapter.IteratorToDoubleIteratorAdapter
All Implemented Interfaces:
DoubleIterator

public class IteratorToDoubleIteratorAdapter
extends Object
implements DoubleIterator

This class represents adaptions of Java Collections Framework iterators to primitive iterators over double values.

Adapters from JCF collections to primitive collections will fail if the JCF collection contains null values or values of the wrong class. However, adapters are not fast failing in the case that the underlying collection should contain illegal values. To implement fast failure would require every operation to check every element of the underlying collection before doing anything. Instead validation methods are provided. They can be called using the assertion facility in the client code:

      CollectionToDoubleCollectionAdapter s;
      ...
      assert s.validate();
  
or by letting the adapter throw an exception on illegal values:
      CollectionToDoubleCollectionAdapter s;
      ...
      s.evalidate();  // Throws an exception on illegal values
  
Either way, validation must be invoked directly by the client code.

Since:
1.0

Constructor Summary
IteratorToDoubleIteratorAdapter(Iterator iterator)
          Creates a new adaption to an iterator over double values.
 
Method Summary
 boolean hasNext()
          Indicates whether more double values can be returned by this iterator.
 double next()
          Returns the next double value of this iterator.
 void remove()
          Removes the last double value returned from the underlying collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IteratorToDoubleIteratorAdapter

public IteratorToDoubleIteratorAdapter(Iterator iterator)
Creates a new adaption to an iterator over double values.

Parameters:
iterator - the underlying iterator. This iterator must return values of class Double. Otherwise a ClassCastException will be thrown by next().
Throws:
NullPointerException - if iterator is null.
Method Detail

hasNext

public boolean hasNext()
Description copied from interface: DoubleIterator
Indicates whether more double values can be returned by this iterator.

Specified by:
hasNext in interface DoubleIterator
Returns:
true if more double values can be returned by this iterator; returns false otherwise.
See Also:
DoubleIterator.next()

next

public double next()
Description copied from interface: DoubleIterator
Returns the next double value of this iterator.

Specified by:
next in interface DoubleIterator
Returns:
the next double value of this iterator.
Throws:
ClassCastException - if the underlying iterator returns an object that is not of class Double.
See Also:
DoubleIterator.hasNext()

remove

public void remove()
Description copied from interface: DoubleIterator
Removes the last double value returned from the underlying collection.

Specified by:
remove in interface DoubleIterator

PCJ API
Version 1.2

Report a bug or request a feature.
Further information on the development and latest release of PCJ can be found at the project homepage.

Primitive Collections for Java is released under the GNU Lesser General Public License.
Copyright © 2002, 2003 Søren Bak. All Rights Reserved.

Hosted by SourceForge.net
SourceForge.net Logo