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