PCJ API
Version 1.2

bak.pcj.adapter
Class ListIteratorToDoubleListIteratorAdapter

java.lang.Object
  extended bybak.pcj.adapter.ListIteratorToDoubleListIteratorAdapter
All Implemented Interfaces:
DoubleIterator, DoubleListIterator

public class ListIteratorToDoubleListIteratorAdapter
extends Object
implements DoubleListIterator

This class represents adaptions of Java Collections Framework list iterators to primitive list 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

Field Summary
protected  ListIterator iterator
          The underlying iterator.
 
Constructor Summary
ListIteratorToDoubleListIteratorAdapter(ListIterator iterator)
          Creates a new adaption of a list iterator to a primitive list iterator over double values.
 
Method Summary
 void add(double v)
          Adds a specified element to the list at this iterator's current position.
 boolean hasNext()
          Indicates whether more double values can be returned by this iterator.
 boolean hasPrevious()
          Indicates whether more double values can be returned by this iterator by calling previous().
 double next()
          Returns the next double value of this iterator.
 int nextIndex()
          Returns the index of the element that would be returned by a call to next().
 double previous()
          Returns the previous double value of this iterator.
 int previousIndex()
          Returns the index of the element that would be returned by a call to previous().
 void remove()
          Removes the last double value returned from the underlying collection.
 void set(double v)
          Sets the last element returned to a specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iterator

protected ListIterator iterator
The underlying iterator.

Constructor Detail

ListIteratorToDoubleListIteratorAdapter

public ListIteratorToDoubleListIteratorAdapter(ListIterator iterator)
Creates a new adaption of a list iterator to a primitive list iterator over double values.

Parameters:
iterator - the iterator to adapt to a primitive iterator.
Throws:
NullPointerException - if iterator is null.
Method Detail

add

public void add(double v)
Description copied from interface: DoubleListIterator
Adds a specified element to the list at this iterator's current position.

Specified by:
add in interface DoubleListIterator
Parameters:
v - the element to add.

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()

hasPrevious

public boolean hasPrevious()
Description copied from interface: DoubleListIterator
Indicates whether more double values can be returned by this iterator by calling previous().

Specified by:
hasPrevious in interface DoubleListIterator
Returns:
true if more double values can be returned by this iterator in backwards direction; returns false otherwise.
See Also:
DoubleListIterator.previous()

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.
See Also:
DoubleIterator.hasNext()

nextIndex

public int nextIndex()
Description copied from interface: DoubleListIterator
Returns the index of the element that would be returned by a call to next().

Specified by:
nextIndex in interface DoubleListIterator
Returns:
the index of the element that would be returned by a call to next().
See Also:
DoubleIterator.next()

previous

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

Specified by:
previous in interface DoubleListIterator
Returns:
the previous double value of this iterator.
See Also:
DoubleListIterator.hasPrevious()

previousIndex

public int previousIndex()
Description copied from interface: DoubleListIterator
Returns the index of the element that would be returned by a call to previous().

Specified by:
previousIndex in interface DoubleListIterator
Returns:
the index of the element that would be returned by a call to previous(); if no more elements are available in backwards direction, -1 is returned.
See Also:
DoubleListIterator.previous()

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

set

public void set(double v)
Description copied from interface: DoubleListIterator
Sets the last element returned to a specified value.

Specified by:
set in interface DoubleListIterator
Parameters:
v - the new value of the element.

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