PCJ API
Version 1.2

bak.pcj.list
Class BooleanArrayList

java.lang.Object
  extended bybak.pcj.AbstractBooleanCollection
      extended bybak.pcj.list.AbstractBooleanList
          extended bybak.pcj.list.BooleanArrayList
All Implemented Interfaces:
BooleanCollection, BooleanList, Cloneable, Serializable
Direct Known Subclasses:
BooleanArrayStack

public class BooleanArrayList
extends AbstractBooleanList
implements Cloneable, Serializable

This class represents an array implemenation of lists of boolean values.

Since:
1.0
See Also:
ArrayList, Serialized Form

Field Summary
static int DEFAULT_CAPACITY
          The default capacity of this list.
static int DEFAULT_GROWTH_CHUNK
          The default chunk size with which to increase the capacity of this list.
static double DEFAULT_GROWTH_FACTOR
          The default factor with which to increase the capacity of this list.
 
Constructor Summary
BooleanArrayList()
          Creates a new array list with capacity 10 and a relative growth factor of 1.0.
BooleanArrayList(boolean[] a)
          Creates a new array list with the same elements as a specified array.
BooleanArrayList(BooleanCollection c)
          Creates a new array list with the same elements as a specified collection.
BooleanArrayList(int capacity)
          Creates a new array list with a specified capacity and a relative growth factor of 1.0.
BooleanArrayList(int capacity, double growthFactor)
          Creates a new array list with a specified capacity and relative growth factor.
BooleanArrayList(int capacity, int growthChunk)
          Creates a new array list with a specified capacity and absolute growth factor.
 
Method Summary
 void add(int index, boolean v)
          Throws UnsupportedOperationException.
 int capacity()
          Returns the current capacity of this list.
 void clear()
          Clears this collection.
 Object clone()
          Returns a clone of this array list.
 boolean contains(boolean v)
          Indicates whether this collection contains a specified element.
 int ensureCapacity(int capacity)
          Ensures that this list has at least a specified capacity.
 boolean equals(Object obj)
          Indicates whether this collection is equal to some object.
 boolean get(int index)
          Returns the element at a specified position in this list.
 int hashCode()
          Returns a hash code value for this collection.
 int indexOf(boolean c)
          Returns the index of the first occurance of a specified element in this list.
 int indexOf(int index, boolean c)
          Returns the index of the first occurance of a specified element in this list after or at a specified index.
 boolean isEmpty()
          Indicates whether this collection is empty.
 int lastIndexOf(boolean c)
          Returns the index of the last occurance of a specified element in this list.
 boolean remove(boolean v)
          Removes a specified element from this collection.
 boolean removeElementAt(int index)
          Throws UnsupportedOperationException.
 boolean set(int index, boolean v)
          Sets a specified element to a new value.
 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.
 void trimToSize()
          Minimizes the memory used by this array list.
 
Methods inherited from class bak.pcj.list.AbstractBooleanList
add, addAll, iterator, lastIndexOf, listIterator, listIterator
 
Methods inherited from class bak.pcj.AbstractBooleanCollection
addAll, containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bak.pcj.BooleanCollection
addAll, containsAll, removeAll, retainAll
 

Field Detail

DEFAULT_GROWTH_FACTOR

public static final double DEFAULT_GROWTH_FACTOR
The default factor with which to increase the capacity of this list.

See Also:
Constant Field Values

DEFAULT_GROWTH_CHUNK

public static final int DEFAULT_GROWTH_CHUNK
The default chunk size with which to increase the capacity of this list.

See Also:
Constant Field Values

DEFAULT_CAPACITY

public static final int DEFAULT_CAPACITY
The default capacity of this list.

See Also:
Constant Field Values
Constructor Detail

BooleanArrayList

public BooleanArrayList()
Creates a new array list with capacity 10 and a relative growth factor of 1.0.

See Also:
BooleanArrayList(int,double)

BooleanArrayList

public BooleanArrayList(BooleanCollection c)
Creates a new array list with the same elements as a specified collection. The elements of the specified collection are added to the end of the list in the collection's iteration order.

Parameters:
c - the collection whose elements to add to the new list.
Throws:
NullPointerException - if c is null.

BooleanArrayList

public BooleanArrayList(boolean[] a)
Creates a new array list with the same elements as a specified array. The elements of the specified array are added to the end of the list in order of the array.

Parameters:
a - the array whose elements to add to the new list.
Throws:
NullPointerException - if a is null.
Since:
1.1

BooleanArrayList

public BooleanArrayList(int capacity)
Creates a new array list with a specified capacity and a relative growth factor of 1.0.

Parameters:
capacity - the initial capacity of the list.
Throws:
IllegalArgumentException - if capacity is negative.
See Also:
BooleanArrayList(int,double)

BooleanArrayList

public BooleanArrayList(int capacity,
                        double growthFactor)
Creates a new array list with a specified capacity and relative growth factor.

The array capacity increases to capacity()*(1+growthFactor). This strategy is good for avoiding many capacity increases, but the amount of wasted memory is approximately the size of the list.

Parameters:
capacity - the initial capacity of the list.
growthFactor - the relative amount with which to increase the the capacity when a capacity increase is needed.
Throws:
IllegalArgumentException - if capacity is negative; if growthFactor is negative.

BooleanArrayList

public BooleanArrayList(int capacity,
                        int growthChunk)
Creates a new array list with a specified capacity and absolute growth factor.

The array capacity increases to capacity()+growthChunk. This strategy is good for avoiding wasting memory. However, an overhead is potentially introduced by frequent capacity increases.

Parameters:
capacity - the initial capacity of the list.
growthChunk - the absolute amount with which to increase the the capacity when a capacity increase is needed.
Throws:
IllegalArgumentException - if capacity is negative; if growthChunk is negative.
Method Detail

ensureCapacity

public int ensureCapacity(int capacity)
Ensures that this list has at least a specified capacity. The actual capacity is calculated from the growth factor or growth chunk specified to the constructor.

Parameters:
capacity - the minimum capacity of this list.
Returns:
the new capacity of this list.
See Also:
capacity()

capacity

public int capacity()
Returns the current capacity of this list. The capacity is the number of elements that the list can contain without having to increase the amount of memory used.

Returns:
the current capacity of this list.
See Also:
ensureCapacity(int)

add

public void add(int index,
                boolean v)
Description copied from class: AbstractBooleanList
Throws UnsupportedOperationException.

Specified by:
add in interface BooleanList
Overrides:
add in class AbstractBooleanList

get

public boolean get(int index)
Description copied from interface: BooleanList
Returns the element at a specified position in this list.

Specified by:
get in interface BooleanList
Parameters:
index - the position of the element to return.
Returns:
the element at the specified position.

set

public boolean set(int index,
                   boolean v)
Description copied from interface: BooleanList
Sets a specified element to a new value.

Specified by:
set in interface BooleanList
Parameters:
index - the index of the element whose value to set.
v - the new value of the specified element.
Returns:
the previous value of the element.

removeElementAt

public boolean removeElementAt(int index)
Description copied from class: AbstractBooleanList
Throws UnsupportedOperationException.

Specified by:
removeElementAt in interface BooleanList
Overrides:
removeElementAt in class AbstractBooleanList

trimToSize

public void trimToSize()
Minimizes the memory used by this array list. The underlying array is replaced by an array whose size is exactly the number of elements in this array list. The method can be used to free up memory after many removals.

Specified by:
trimToSize in interface BooleanCollection
Overrides:
trimToSize in class AbstractBooleanCollection

clone

public Object clone()
Returns a clone of this array list.

Returns:
a clone of this array list.
Since:
1.1

size

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

Specified by:
size in interface BooleanCollection
Overrides:
size in class AbstractBooleanCollection

isEmpty

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

Specified by:
isEmpty in interface BooleanCollection
Overrides:
isEmpty in class AbstractBooleanCollection

clear

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

Specified by:
clear in interface BooleanCollection
Overrides:
clear in class AbstractBooleanCollection

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
Overrides:
contains in class AbstractBooleanCollection

indexOf

public int indexOf(boolean c)
Description copied from interface: BooleanList
Returns the index of the first occurance of a specified element in this list.

Specified by:
indexOf in interface BooleanList
Overrides:
indexOf in class AbstractBooleanList

indexOf

public int indexOf(int index,
                   boolean c)
Description copied from interface: BooleanList
Returns the index of the first occurance of a specified element in this list after or at a specified index.

Specified by:
indexOf in interface BooleanList
Overrides:
indexOf in class AbstractBooleanList
Since:
1.2

lastIndexOf

public int lastIndexOf(boolean c)
Description copied from interface: BooleanList
Returns the index of the last occurance of a specified element in this list.

Specified by:
lastIndexOf in interface BooleanList
Overrides:
lastIndexOf in class AbstractBooleanList

remove

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

Specified by:
remove in interface BooleanCollection
Overrides:
remove in class AbstractBooleanCollection

toArray

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

Specified by:
toArray in interface BooleanCollection
Overrides:
toArray in class AbstractBooleanCollection

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
Overrides:
toArray in class AbstractBooleanCollection

equals

public boolean equals(Object obj)
Description copied from interface: BooleanCollection
Indicates whether this collection is equal to some object.

Specified by:
equals in interface BooleanCollection
Overrides:
equals in class AbstractBooleanList

hashCode

public int hashCode()
Description copied from interface: BooleanCollection
Returns a hash code value for this collection.

Specified by:
hashCode in interface BooleanCollection
Overrides:
hashCode in class AbstractBooleanList

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