Package com.ibm.wala.util.collections
Class ImmutableStack<T>
java.lang.Object
com.ibm.wala.util.collections.ImmutableStack<T>
- All Implemented Interfaces:
Iterable<T>
- Direct Known Subclasses:
CallStack
An immutable stack of objects. The
push(Object)
and pop()
operations create new
stacks.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static final <T> ImmutableStack<T>
boolean
get
(int i) static int
int
hashCode()
boolean
isEmpty()
iterator()
protected T[]
makeInternalArray
(int size) protected ImmutableStack<T>
peek()
pop()
popAll
(ImmutableStack<T> other) pushAll
(ImmutableStack<T> other) replaceTop
(T t) return a new stack with the top replaced with treverse()
int
size()
boolean
topMatches
(ImmutableStack<T> other) toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ImmutableStack
-
-
Method Details
-
getMaxSize
public static int getMaxSize() -
emptyStack
-
equals
-
hashCode
public int hashCode() -
push
-
makeInternalArray
-
makeStack
-
peek
- Returns:
- the element on the top of the stack
- Throws:
EmptyStackException
- if stack is empty
-
pop
- Throws:
EmptyStackException
- if stack is empty
-
isEmpty
public boolean isEmpty() -
size
public int size() -
get
-
toString
-
contains
-
topMatches
- Returns:
true
iffother.size() = k
,k <= this.size()
, and the top k elements of this equal other- Throws:
IllegalArgumentException
- if other == null
-
reverse
-
popAll
-
pushAll
-
iterator
-
replaceTop
return a new stack with the top replaced with t
-