|
PCJ API Version 1.2 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectbak.pcj.AbstractLongCollection
bak.pcj.adapter.CollectionToLongCollectionAdapter
This class represents adaptions of Java Collections Framework collections to primitive collections of long values. The adapter is implemented as a wrapper around the collection. Thus, changes to the underlying collection are reflected by this collection and vice versa.
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 values
Either way, validation must be invoked directly by the client
code.
| Field Summary | |
protected Collection |
collection
The underlying collection. |
| Constructor Summary | |
CollectionToLongCollectionAdapter(Collection collection)
Creates a new adaption of a collection to a collection of long values. |
|
CollectionToLongCollectionAdapter(Collection collection,
boolean validate)
Creates a new adaption of a collection to a collection of long values. |
|
| Method Summary | |
boolean |
add(long v)
Throws UnsupportedOperationException. |
void |
clear()
Clears this collection. |
boolean |
contains(long v)
Indicates whether this collection contains a specified element. |
void |
evalidate()
Validates the collection underlying this adapter and throws an exception if it is invalid. |
int |
hashCode()
Returns a hash code value for this collection. |
LongIterator |
iterator()
Returns an iterator over this collection. |
boolean |
remove(long v)
Removes a specified element from this collection. |
int |
size()
Returns the number of elements in this collection. |
boolean |
validate()
Indicates whether the underlying collection is valid for this adapter. |
| Methods inherited from class bak.pcj.AbstractLongCollection |
addAll, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString, trimToSize |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface bak.pcj.LongCollection |
equals |
| Field Detail |
protected Collection collection
| Constructor Detail |
public CollectionToLongCollectionAdapter(Collection collection)
collection - the underlying collection. This collection must
consist of values of class
Long. Otherwise a
ClassCastException
will be thrown by some methods.
NullPointerException - if collection is null.
public CollectionToLongCollectionAdapter(Collection collection,
boolean validate)
collection - the underlying collection. This collection must
consist of values of class
Long. Otherwise a
ClassCastException
will be thrown by some methods.validate - indicates whether collection should
be checked for illegal values.
NullPointerException - if collection is null.
IllegalStateException - if validate is true and
collection contains a null value
or a value that is not of class
Long.| Method Detail |
public boolean add(long v)
AbstractLongCollection
add in interface LongCollectionadd in class AbstractLongCollectionpublic void clear()
LongCollection
clear in interface LongCollectionclear in class AbstractLongCollectionpublic boolean contains(long v)
LongCollection
contains in interface LongCollectioncontains in class AbstractLongCollectionpublic int hashCode()
LongCollection
public LongIterator iterator()
LongCollection
public boolean remove(long v)
LongCollection
remove in interface LongCollectionremove in class AbstractLongCollectionpublic int size()
LongCollection
size in interface LongCollectionsize in class AbstractLongCollectionpublic boolean validate()
Long values and no null
values.
public void evalidate()
Long
values and no null values.
IllegalStateException - if the underlying collection is invalid.
|
PCJ API Version 1.2 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||