PCJ API
Version 1.2

bak.pcj.list
Class FloatArrayDeque

java.lang.Object
  extended bybak.pcj.AbstractFloatCollection
      extended bybak.pcj.list.AbstractFloatList
          extended bybak.pcj.list.FloatArrayDeque
All Implemented Interfaces:
Cloneable, FloatCollection, FloatDeque, FloatList, Serializable

public class FloatArrayDeque
extends AbstractFloatList
implements FloatDeque, Cloneable, Serializable

This class represents an array implementaion of deques of float values.

Since:
1.0
See Also:
LinkedList, Serialized Form

Field Summary
static int DEFAULT_CAPACITY
          The default capacity of this deque.
static int DEFAULT_GROWTH_CHUNK
          The default chunk size with which to increase the capacity of this deque.
static double DEFAULT_GROWTH_FACTOR
          The default factor with which to increase the capacity of this deque.
 
Constructor Summary
FloatArrayDeque()
          Creates a new array deque with capacity 10 and a relative growth factor of 1.0.
FloatArrayDeque(float[] a)
          Creates a new array deque with the same elements as a specified array.
FloatArrayDeque(FloatCollection c)
          Creates a new array deque with the same elements as a specified collection.
FloatArrayDeque(int capacity)
          Creates a new array deque with a specified capacity and a relative growth factor of 1.0.
FloatArrayDeque(int capacity, double growthFactor)
          Creates a new array deque with a specified capacity and relative growth factor.
FloatArrayDeque(int capacity, int growthChunk)
          Creates a new array deque with a specified capacity and absolute growth factor.
 
Method Summary
 void add(int index, float v)
          Adds an element to this list at a specified index.
 void addFirst(float v)
          Adds an element to the beginning of this deque.
 void addLast(float v)
          Adds an element to the end of this deque.
 int capacity()
          Returns the current capacity of this deque.
 void clear()
          Clears this collection.
 Object clone()
          Returns a clone of this array deque.
 boolean contains(float v)
          Indicates whether this collection contains a specified element.
 int ensureCapacity(int capacity)
          Ensures that this deque has at least a specified capacity.
 boolean equals(Object obj)
          Indicates whether this collection is equal to some object.
 float get(int index)
          Returns the element at a specified position in this list.
 float getFirst()
          Returns the first element of this deque.
 float getLast()
          Returns the last element of this deque.
 int hashCode()
          Returns a hash code value for this collection.
 int indexOf(float c)
          Returns the index of the first occurance of a specified element in this list.
 boolean isEmpty()
          Indicates whether this collection is empty.
 int lastIndexOf(float c)
          Returns the index of the last occurance of a specified element in this list.
 boolean remove(float v)
          Removes a specified element from this collection.
 float removeElementAt(int index)
          Removes the element at a specified index in this list.
 float removeFirst()
          Removes the first element of this deque.
 float removeLast()
          Removes the last element of this deque.
 float set(int index, float v)
          Sets a specified element to a new value.
 int size()
          Returns the number of elements in this collection.
 float[] toArray(float[] a)
          Returns the elements of this collection as an array.
 void trimToSize()
          Minimizes the memory used by this array deque.
 
Methods inherited from class bak.pcj.list.AbstractFloatList
add, addAll, indexOf, iterator, lastIndexOf, listIterator, listIterator
 
Methods inherited from class bak.pcj.AbstractFloatCollection
addAll, containsAll, removeAll, retainAll, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface bak.pcj.list.FloatList
addAll, indexOf, lastIndexOf, listIterator, listIterator
 
Methods inherited from interface bak.pcj.FloatCollection
add, addAll, containsAll, iterator, removeAll, retainAll, toArray
 

Field Detail

DEFAULT_GROWTH_FACTOR

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

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 deque.

See Also:
Constant Field Values

DEFAULT_CAPACITY

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

See Also:
Constant Field Values
Constructor Detail

FloatArrayDeque

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

See Also:
FloatArrayDeque(int,double)

FloatArrayDeque

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

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

FloatArrayDeque

public FloatArrayDeque(float[] a)
Creates a new array deque with the same elements as a specified array. The elements of the specified array are added the end of the deque in the order in which they appear in the array.

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

FloatArrayDeque

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

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

FloatArrayDeque

public FloatArrayDeque(int capacity,
                       double growthFactor)
Creates a new array deque 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 deque.

Parameters:
capacity - the initial capacity of the deque.
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.

FloatArrayDeque

public FloatArrayDeque(int capacity,
                       int growthChunk)
Creates a new array deque 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 deque.
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 deque 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 deque.
Returns:
the new capacity of this deque.
See Also:
capacity()

capacity

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

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

add

public void add(int index,
                float v)
Description copied from interface: FloatList
Adds an element to this list at a specified index. All elements from the specified index and forward are pushed to their successor's indices.

Specified by:
add in interface FloatList
Overrides:
add in class AbstractFloatList

get

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

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

set

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

Specified by:
set in interface FloatList
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 float removeElementAt(int index)
Description copied from interface: FloatList
Removes the element at a specified index in this list. All elements following the removed element are pushed to their predecessor's indices.

Specified by:
removeElementAt in interface FloatList
Overrides:
removeElementAt in class AbstractFloatList

trimToSize

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

Specified by:
trimToSize in interface FloatCollection
Overrides:
trimToSize in class AbstractFloatCollection

clone

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

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

getFirst

public float getFirst()
Description copied from interface: FloatDeque
Returns the first element of this deque.

Specified by:
getFirst in interface FloatDeque
Returns:
the first element of this deque.

getLast

public float getLast()
Description copied from interface: FloatDeque
Returns the last element of this deque.

Specified by:
getLast in interface FloatDeque
Returns:
the first element of this deque.

addFirst

public void addFirst(float v)
Description copied from interface: FloatDeque
Adds an element to the beginning of this deque.

Specified by:
addFirst in interface FloatDeque
Parameters:
v - the element to add to this deque.

addLast

public void addLast(float v)
Description copied from interface: FloatDeque
Adds an element to the end of this deque.

Specified by:
addLast in interface FloatDeque
Parameters:
v - the element to add to this deque.

removeFirst

public float removeFirst()
Description copied from interface: FloatDeque
Removes the first element of this deque.

Specified by:
removeFirst in interface FloatDeque
Returns:
the element that was removed.

removeLast

public float removeLast()
Description copied from interface: FloatDeque
Removes the last element of this deque.

Specified by:
removeLast in interface FloatDeque
Returns:
the element that was removed.

size

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

Specified by:
size in interface FloatCollection
Overrides:
size in class AbstractFloatCollection

isEmpty

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

Specified by:
isEmpty in interface FloatCollection
Overrides:
isEmpty in class AbstractFloatCollection

clear

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

Specified by:
clear in interface FloatCollection
Overrides:
clear in class AbstractFloatCollection

contains

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

Specified by:
contains in interface FloatCollection
Overrides:
contains in class AbstractFloatCollection

indexOf

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

Specified by:
indexOf in interface FloatList
Overrides:
indexOf in class AbstractFloatList

lastIndexOf

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

Specified by:
lastIndexOf in interface FloatList
Overrides:
lastIndexOf in class AbstractFloatList

remove

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

Specified by:
remove in interface FloatCollection
Overrides:
remove in class AbstractFloatCollection

toArray

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

Specified by:
toArray in interface FloatCollection
Overrides:
toArray in class AbstractFloatCollection

equals

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

Specified by:
equals in interface FloatCollection
Overrides:
equals in class AbstractFloatList

hashCode

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

Specified by:
hashCode in interface FloatCollection
Overrides:
hashCode in class AbstractFloatList

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