T
- The type of elements to be stored in the stack.public class Stack<T> extends java.lang.Object implements java.io.Serializable, RevisionHandler
Modifier and Type | Field and Description |
---|---|
java.util.ArrayList<T> |
elements
The elements inside the stack.
|
int |
length
The number of elements in the stack.
|
Constructor and Description |
---|
Stack()
Constructor.
|
Stack(int capacity)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addAll(java.util.Collection<? extends T> c)
Adds all the given elements in the stack.
|
void |
clear()
Removes all the elements from the stack.
|
T |
element(int i)
Returns the ith element in the stack.
|
java.lang.String |
getRevision()
Returns the revision string.
|
T |
last()
Returns the last element in the stack.
|
T |
pop()
Pops (removes) the first (last added) element in the stack.
|
void |
push(Stack<T> v,
T new_ele)
Pushes the given element onto the given stack.
|
void |
push(T new_ele)
Pushes the given element to the stack.
|
void |
replaceAllBy(Stack<T> s)
Replace all elements in the stack with the elements of another given stack.
|
void |
set(int i,
T e)
Sets the ith element in the stack.
|
java.util.List<T> |
subList(int beginIdx,
int uptoLength)
Returns a sublist of the elements in the stack.
|
public int length
public java.util.ArrayList<T> elements
public Stack()
public Stack(int capacity)
capacity
- The initial capacity of the stack.public T last()
public T element(int i)
i
- The index of the element to return.public void set(int i, T e)
i
- The index at which the element is to be inserted.e
- The element to insert.public java.util.List<T> subList(int beginIdx, int uptoLength)
beginIdx
- The start index of the sublist.uptoLength
- The length of the sublist.public void clear()
public void addAll(java.util.Collection<? extends T> c)
c
- The collection of elements to add in the stack.public void replaceAllBy(Stack<T> s)
s
- The stack whose elements should be put in this stack.public T pop()
public void push(T new_ele)
new_ele
- The element to be pushed to the stack.public void push(Stack<T> v, T new_ele)
v
- The stack onto push the element.new_ele
- The element to push.public java.lang.String getRevision()
getRevision
in interface RevisionHandler