PCJ API
Version 1.2

bak.pcj.adapter
Class SortedSetToBooleanSortedSetAdapter

java.lang.Object
  extended bybak.pcj.AbstractBooleanCollection
      extended bybak.pcj.set.AbstractBooleanSet
          extended bybak.pcj.adapter.SetToBooleanSetAdapter
              extended bybak.pcj.adapter.SortedSetToBooleanSortedSetAdapter
All Implemented Interfaces:
BooleanCollection, BooleanSet, BooleanSortedSet

public class SortedSetToBooleanSortedSetAdapter
extends SetToBooleanSetAdapter
implements BooleanSortedSet

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:

      SortedSetToBooleanSortedSetAdapter s;
      ...
      assert s.validate();
  
or by letting the adapter throw an exception on illegal values:
      SortedSetToBooleanSortedSetAdapter s;
      ...
      s.evalidate();  // Throws an exception on illegal values
  
Either way, validation must be invoked directly by the client code.

Since:
1.2

Field Summary
 
Fields inherited from class bak.pcj.adapter.SetToBooleanSetAdapter
set
 
Constructor Summary
SortedSetToBooleanSortedSetAdapter(SortedSet set)
          Creates a new adaption to a set of boolean values.
SortedSetToBooleanSortedSetAdapter(SortedSet set, boolean validate)
          Creates a new adaption to a set of boolean values.
 
Method Summary
 boolean first()
          Returns the lowest element of this set.
 BooleanSortedSet headSet(boolean to)
          Returns the subset of values lower than a specified value.
 boolean last()
          Returns the highest element of this set.
 BooleanSortedSet subSet(boolean from, boolean to)
          Returns the subset of values lower that a specified value and higher than or equal to another specified value.
 BooleanSortedSet tailSet(boolean from)
          Returns the subset of values higher than or equal to a specified value.
 
Methods inherited from class bak.pcj.adapter.SetToBooleanSetAdapter
add, clear, contains, evalidate, hashCode, iterator, remove, size, validate
 
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.set.BooleanSortedSet
add
 
Methods inherited from interface bak.pcj.BooleanCollection
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, trimToSize
 

Constructor Detail

SortedSetToBooleanSortedSetAdapter

public SortedSetToBooleanSortedSetAdapter(SortedSet set)
Creates a new adaption to a set of boolean values.

Parameters:
set - the underlying set. This set must consist of values of class Boolean. Otherwise a ClassCastException will be thrown by some methods.
Throws:
NullPointerException - if set is null.

SortedSetToBooleanSortedSetAdapter

public SortedSetToBooleanSortedSetAdapter(SortedSet set,
                                          boolean validate)
Creates a new adaption to a set of boolean values. The set to adapt is optionally validated.

Parameters:
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.
Throws:
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

first

public boolean first()
Description copied from interface: BooleanSortedSet
Returns the lowest element of this set.

Specified by:
first in interface BooleanSortedSet
Returns:
the lowest element of this set.

headSet

public BooleanSortedSet headSet(boolean to)
Description copied from interface: BooleanSortedSet
Returns the subset of values lower than a specified value. The returned subset is a view of this set, so changes to the subset are reflected by this set and vice versa.

Specified by:
headSet in interface BooleanSortedSet
Parameters:
to - the upper bound of the returned set (not included).

last

public boolean last()
Description copied from interface: BooleanSortedSet
Returns the highest element of this set.

Specified by:
last in interface BooleanSortedSet
Returns:
the highest element of this set.

subSet

public BooleanSortedSet subSet(boolean from,
                               boolean to)
Description copied from interface: BooleanSortedSet
Returns the subset of values lower that a specified value and higher than or equal to another specified value. The returned subset is a view of this set, so changes to the subset are reflected by this set and vice versa.

Specified by:
subSet in interface BooleanSortedSet
Parameters:
from - the lower bound of the returned set (included).
to - the upper bound of the returned set (not included).

tailSet

public BooleanSortedSet tailSet(boolean from)
Description copied from interface: BooleanSortedSet
Returns the subset of values higher than or equal to a specified value. The returned subset is a view of this set, so changes to the subset are reflected by this set and vice versa.

Specified by:
tailSet in interface BooleanSortedSet
Parameters:
from - the lower bound of the returned set (included).

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