PCJ API
Version 1.2

bak.pcj.list
Class LongArrayStack

java.lang.Object
  extended bybak.pcj.AbstractLongCollection
      extended bybak.pcj.list.AbstractLongList
          extended bybak.pcj.list.LongArrayList
              extended bybak.pcj.list.LongArrayStack
All Implemented Interfaces:
Cloneable, LongCollection, LongList, LongStack, Serializable

public class LongArrayStack
extends LongArrayList
implements LongStack

This class represents an array implemenation of stacks of long values.

Since:
1.0
See Also:
ArrayList, Serialized Form

Field Summary
 
Fields inherited from class bak.pcj.list.LongArrayList
DEFAULT_CAPACITY, DEFAULT_GROWTH_CHUNK, DEFAULT_GROWTH_FACTOR
 
Constructor Summary
LongArrayStack()
          Creates a new array stack with capacity 10 and a relative growth factor of 1.0.
LongArrayStack(int capacity)
          Creates a new array stack with a specified capacity and a relative growth factor of 1.0.
LongArrayStack(int capacity, double growthFactor)
          Creates a new array stack with a specified capacity and relative growth factor.
LongArrayStack(int capacity, int growthChunk)
          Creates a new array stack with a specified capacity and absolute growth factor.
LongArrayStack(long[] a)
          Creates a new array stack with the same elements as a specified array.
LongArrayStack(LongCollection c)
          Creates a new array stack with the same elements as a specified collection.
 
Method Summary
 long peek()
          Returns the top element of this stack.
 long pop()
          Pops an element off this stack.
 void push(long v)
          Pushes a specified element onto this stack.
 
Methods inherited from class bak.pcj.list.LongArrayList
add, capacity, clear, clone, contains, ensureCapacity, equals, get, hashCode, indexOf, indexOf, isEmpty, lastIndexOf, remove, removeElementAt, set, size, toArray, toArray, trimToSize
 
Methods inherited from class bak.pcj.list.AbstractLongList
add, addAll, iterator, lastIndexOf, listIterator, listIterator
 
Methods inherited from class bak.pcj.AbstractLongCollection
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.list.LongList
add, addAll, get, indexOf, indexOf, lastIndexOf, lastIndexOf, listIterator, listIterator, removeElementAt, set
 
Methods inherited from interface bak.pcj.LongCollection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, trimToSize
 

Constructor Detail

LongArrayStack

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

See Also:
LongArrayStack(int,double)

LongArrayStack

public LongArrayStack(LongCollection c)
Creates a new array stack with the same elements as a specified collection. The elements of the specified collection are pushed in the collection's iteration order.

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

LongArrayStack

public LongArrayStack(long[] a)
Creates a new array stack with the same elements as a specified array. The elements of the specified array are pushed in the order of the array.

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

LongArrayStack

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

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

LongArrayStack

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

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

LongArrayStack

public LongArrayStack(int capacity,
                      int growthChunk)
Creates a new array stack 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 stack.
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

push

public void push(long v)
Description copied from interface: LongStack
Pushes a specified element onto this stack.

Specified by:
push in interface LongStack
Parameters:
v - the element to push onto this stack.

pop

public long pop()
Description copied from interface: LongStack
Pops an element off this stack.

Specified by:
pop in interface LongStack
Returns:
the element that was popped off this stack.
See Also:
LongStack.peek()

peek

public long peek()
Description copied from interface: LongStack
Returns the top element of this stack.

Specified by:
peek in interface LongStack
Returns:
the top element of this stack.
See Also:
LongStack.pop()

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