PCJ API
Version 1.2

bak.pcj
Class AbstractBooleanCollection

java.lang.Object
  extended bybak.pcj.AbstractBooleanCollection
All Implemented Interfaces:
BooleanCollection
Direct Known Subclasses:
AbstractBooleanList, AbstractBooleanSet, CollectionToBooleanCollectionAdapter

public abstract class AbstractBooleanCollection
extends Object
implements BooleanCollection

This class represents an abstract base for implementing collections of boolean values. All operations that can be implemented using iterators are implemented as such. In most cases, this is hardly an efficient solution, and at least some of those methods should be overridden by sub-classes.

In this implementation, size() is calculated by iterating over the collection. Make sure that size() is overwritten or that iterators do not depend on the size() method.

Since:
1.0

Constructor Summary
protected AbstractBooleanCollection()
          Default constructor to be invoked by sub-classes.
 
Method Summary
 boolean add(boolean v)
          Throws UnsupportedOperationException.
 boolean addAll(BooleanCollection c)
          Adds all the elements of a specified collection to this collection.
 void clear()
          Clears this collection.
 boolean contains(boolean v)
          Indicates whether this collection contains a specified element.
 boolean containsAll(BooleanCollection c)
          Indicates whether all elements of a specified collection is contained in this collection.
 boolean isEmpty()
          Indicates whether this collection is empty.
 boolean remove(boolean v)
          Removes a specified element from this collection.
 boolean removeAll(BooleanCollection c)
          Removes all the elements of a specified collection from this collection.
 boolean retainAll(BooleanCollection c)
          Retains only the elements of a specified collection in this collection.
 int size()
          Returns the number of elements in this collection.
 boolean[] toArray()
          Returns the elements of this collection as an array.
 boolean[] toArray(boolean[] a)
          Returns the elements of this collection as an array.
 String toString()
          Returns a string representation of this collection.
 void trimToSize()
          Does nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bak.pcj.BooleanCollection
equals, hashCode, iterator
 

Constructor Detail

AbstractBooleanCollection

protected AbstractBooleanCollection()
Default constructor to be invoked by sub-classes.

Method Detail

add

public boolean add(boolean v)
Throws UnsupportedOperationException.

Specified by:
add in interface BooleanCollection
Parameters:
v - the element to add to this collection.
Returns:
true if this collection was modified as a result of adding v; returns false otherwise.
Throws:
UnsupportedOperationException - unconditionally.
See Also:
BooleanCollection.addAll(BooleanCollection)

addAll

public boolean addAll(BooleanCollection c)
Description copied from interface: BooleanCollection
Adds all the elements of a specified collection to this collection.

Specified by:
addAll in interface BooleanCollection
Parameters:
c - the collection whose elements to add to this collection.
Returns:
true if this collection was modified as a result of adding the elements of c; returns false otherwise.
See Also:
BooleanCollection.add(boolean)

clear

public void clear()
Description copied from interface: BooleanCollection
Clears this collection.

Specified by:
clear in interface BooleanCollection

contains

public boolean contains(boolean v)
Description copied from interface: BooleanCollection
Indicates whether this collection contains a specified element.

Specified by:
contains in interface BooleanCollection
Parameters:
v - the element to test for containment.
Returns:
true if v is contained in this collection; returns false otherwise.
See Also:
BooleanCollection.containsAll(BooleanCollection)

containsAll

public boolean containsAll(BooleanCollection c)
Description copied from interface: BooleanCollection
Indicates whether all elements of a specified collection is contained in this collection.

Specified by:
containsAll in interface BooleanCollection
Parameters:
c - the collection whose elements to test for containment.
Returns:
true if all the elements of c are contained in this collection; returns false otherwise.
See Also:
BooleanCollection.contains(boolean)

isEmpty

public boolean isEmpty()
Description copied from interface: BooleanCollection
Indicates whether this collection is empty.

Specified by:
isEmpty in interface BooleanCollection
Returns:
true if this collection is empty; returns false otherwise.

remove

public boolean remove(boolean v)
Description copied from interface: BooleanCollection
Removes a specified element from this collection.

Specified by:
remove in interface BooleanCollection
Parameters:
v - the boolean value to remove from this collection.
Returns:
true if this collection was modified as a result of removing v; returns false otherwise.

removeAll

public boolean removeAll(BooleanCollection c)
Description copied from interface: BooleanCollection
Removes all the elements of a specified collection from this collection.

Specified by:
removeAll in interface BooleanCollection
Parameters:
c - the collection whose elements to remove from this collection.
Returns:
true if this collection was modified as a result of removing the elements of c; returns false otherwise.

retainAll

public boolean retainAll(BooleanCollection c)
Description copied from interface: BooleanCollection
Retains only the elements of a specified collection in this collection.

Specified by:
retainAll in interface BooleanCollection
Parameters:
c - the collection whose elements to retain in this collection.
Returns:
true if this collection was modified as a result of removing the elements not contained in c; returns false otherwise.

size

public int size()
Description copied from interface: BooleanCollection
Returns the number of elements in this collection.

Specified by:
size in interface BooleanCollection
Returns:
the number of elements in this collection.

toArray

public boolean[] toArray()
Description copied from interface: BooleanCollection
Returns the elements of this collection as an array.

Specified by:
toArray in interface BooleanCollection
Returns:
a new array containing the elements of this collection.

toArray

public boolean[] toArray(boolean[] a)
Description copied from interface: BooleanCollection
Returns the elements of this collection as an array.

Specified by:
toArray in interface BooleanCollection
Parameters:
a - an array to fill with the elements of this collection; if a is null or not big enough to contain all the elements of this collection, an new array is allocated, and a is not changed.
Returns:
a, if a has room for all the elements of this collection; otherwise a new array is allocated, filled with the elements of this collection, and returned.

trimToSize

public void trimToSize()
Does nothing. Sub-classes may provide an implementation to minimize memory usage, but this is not required since many implementations will always have minimal memory usage.

Specified by:
trimToSize in interface BooleanCollection

toString

public String toString()
Returns a string representation of this collection.

Returns:
a string representation of this collection.

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