com.sun.jts.pi
Class ArrayListStack

java.lang.Object
  extended by com.sun.jts.pi.ArrayListStack

public class ArrayListStack
extends java.lang.Object

The ArrayListStack class represents a last-in-first-out (LIFO) stack of objects. It encapsulates class ArrayList with four operations that allow a list to be treated as a stack. The usual push and pop operations are provided, as well as a method to peek at the top item on the stack, and a method to test for whether the stack is empty

When a stack is first created, it contains no items.

Version:
$Revision: 1.3 $ on $Date: 2005/12/25 04:12:09 $
Author:
Darpan Dinker, $Author: tcfujii $

Constructor Summary
ArrayListStack()
          Creates a stack with a default size
ArrayListStack(int size)
          Creates a stack with the given initial size
 
Method Summary
 boolean empty()
          Tests if this stack is empty.
 java.lang.Object peek()
          Looks at the object at the top of this stack without removing it from the stack.
 java.lang.Object pop()
          Removes the object at the top of this stack and returns that object as the value of this function.
 void push(java.lang.Object obj)
          Pushes an item onto the top of this stack.
 int size()
          Provides the current size of the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArrayListStack

public ArrayListStack(int size)
Creates a stack with the given initial size


ArrayListStack

public ArrayListStack()
Creates a stack with a default size

Method Detail

size

public int size()
Provides the current size of the stack.

Returns:
int return the current size.

push

public void push(java.lang.Object obj)
Pushes an item onto the top of this stack. This method will internally add elements to the ArrayList if the stack is full.

Parameters:
obj - the object to be pushed onto this stack.
See Also:
ArrayList.add(E)

pop

public java.lang.Object pop()
Removes the object at the top of this stack and returns that object as the value of this function.

Returns:
The object at the top of this stack (the last item of the ArrayList object). Null if stack is empty.

empty

public boolean empty()
Tests if this stack is empty.

Returns:
true if and only if this stack contains no items; false otherwise.

peek

public java.lang.Object peek()
Looks at the object at the top of this stack without removing it from the stack.

Returns:
the object at the top of this stack (the last item of the ArrayList object). Null if stack is empty.


Copyright © 2012 GlassFish Community. All Rights Reserved.