|
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.AbstractDoubleCollection bak.pcj.set.AbstractDoubleSet bak.pcj.adapter.SetToDoubleSetAdapter bak.pcj.adapter.SortedSetToDoubleSortedSetAdapter
This class represents adaptions of Java Collections Framework sets to primitive sets of double 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:
SortedSetToDoubleSortedSetAdapter s; ... assert s.validate();or by letting the adapter throw an exception on illegal values:
SortedSetToDoubleSortedSetAdapter s; ... s.evalidate(); // Throws an exception on illegal valuesEither way, validation must be invoked directly by the client code.
Field Summary |
Fields inherited from class bak.pcj.adapter.SetToDoubleSetAdapter |
set |
Constructor Summary | |
SortedSetToDoubleSortedSetAdapter(SortedSet set)
Creates a new adaption to a set of double values. |
|
SortedSetToDoubleSortedSetAdapter(SortedSet set,
boolean validate)
Creates a new adaption to a set of double values. |
Method Summary | |
double |
first()
Returns the lowest element of this set. |
DoubleSortedSet |
headSet(double to)
Returns the subset of values lower than a specified value. |
double |
last()
Returns the highest element of this set. |
DoubleSortedSet |
subSet(double from,
double to)
Returns the subset of values lower that a specified value and higher than or equal to another specified value. |
DoubleSortedSet |
tailSet(double from)
Returns the subset of values higher than or equal to a specified value. |
Methods inherited from class bak.pcj.adapter.SetToDoubleSetAdapter |
add, clear, contains, evalidate, hashCode, iterator, remove, size, validate |
Methods inherited from class bak.pcj.set.AbstractDoubleSet |
equals |
Methods inherited from class bak.pcj.AbstractDoubleCollection |
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.set.DoubleSortedSet |
add |
Methods inherited from interface bak.pcj.DoubleCollection |
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, trimToSize |
Constructor Detail |
public SortedSetToDoubleSortedSetAdapter(SortedSet set)
set
- the underlying set. This set must
consist of values of class
Double
. Otherwise a
ClassCastException
will be thrown by some methods.
NullPointerException
- if set is null.public SortedSetToDoubleSortedSetAdapter(SortedSet set, boolean validate)
set
- the underlying set. This set must
consist of values of class
Double
. 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
Double
.Method Detail |
public double first()
DoubleSortedSet
first
in interface DoubleSortedSet
public DoubleSortedSet headSet(double to)
DoubleSortedSet
headSet
in interface DoubleSortedSet
to
- the upper bound of the returned set (not included).public double last()
DoubleSortedSet
last
in interface DoubleSortedSet
public DoubleSortedSet subSet(double from, double to)
DoubleSortedSet
subSet
in interface DoubleSortedSet
from
- the lower bound of the returned set (included).to
- the upper bound of the returned set (not included).public DoubleSortedSet tailSet(double from)
DoubleSortedSet
tailSet
in interface DoubleSortedSet
from
- the lower bound of the returned set (included).
|
PCJ API Version 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |