Package com.sun.jts.pi
Class ArrayListStack
- java.lang.Object
-
- com.sun.jts.pi.ArrayListStack
-
public class ArrayListStack extends Object
TheArrayListStack
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 emptyWhen 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
Constructors Constructor Description ArrayListStack()
Creates a stack with a default sizeArrayListStack(int size)
Creates a stack with the given initial size
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
empty()
Tests if this stack is empty.Object
peek()
Looks at the object at the top of this stack without removing it from the stack.Object
pop()
Removes the object at the top of this stack and returns that object as the value of this function.void
push(Object obj)
Pushes an item onto the top of this stack.int
size()
Provides the current size of the stack.
-
-
-
Method Detail
-
size
public int size()
Provides the current size of the stack.- Returns:
- int return the current size.
-
push
public void push(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, java.lang.Object[], int)
-
pop
public 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 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.
-
-