|
PCJ API Version 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bak.pcj.adapter.IteratorToLongIteratorAdapter
This class represents adaptions of Java Collections Framework iterators to primitive iterators over long 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:
CollectionToLongCollectionAdapter s; ... assert s.validate();or by letting the adapter throw an exception on illegal values:
CollectionToLongCollectionAdapter s; ... s.evalidate(); // Throws an exception on illegal valuesEither way, validation must be invoked directly by the client code.
Constructor Summary | |
IteratorToLongIteratorAdapter(Iterator iterator)
Creates a new adaption to an iterator over long values. |
Method Summary | |
boolean |
hasNext()
Indicates whether more long values can be returned by this iterator. |
long |
next()
Returns the next long value of this iterator. |
void |
remove()
Removes the last long 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 |
public IteratorToLongIteratorAdapter(Iterator iterator)
iterator
- the underlying iterator. This iterator must
return values of class
Long
. Otherwise a
ClassCastException
will be thrown by
next()
.
NullPointerException
- if iterator is null.Method Detail |
public boolean hasNext()
LongIterator
hasNext
in interface LongIterator
LongIterator.next()
public long next()
LongIterator
next
in interface LongIterator
ClassCastException
- if the underlying iterator returns an object
that is not of class
Long
.LongIterator.hasNext()
public void remove()
LongIterator
remove
in interface LongIterator
|
PCJ API Version 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |