Package com.ibm.wala.util.collections
Class ImmutableStack<T>
- java.lang.Object
-
- com.ibm.wala.util.collections.ImmutableStack<T>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ImmutableStack(T[] entries)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(T entry)
static <T> ImmutableStack<T>
emptyStack()
boolean
equals(Object o)
T
get(int i)
static int
getMaxSize()
int
hashCode()
boolean
isEmpty()
Iterator<T>
iterator()
protected T[]
makeInternalArray(int size)
protected ImmutableStack<T>
makeStack(T[] tmpEntries)
T
peek()
ImmutableStack<T>
pop()
ImmutableStack<T>
popAll(ImmutableStack<T> other)
ImmutableStack<T>
push(T entry)
ImmutableStack<T>
pushAll(ImmutableStack<T> other)
ImmutableStack<T>
replaceTop(T t)
return a new stack with the top replaced with tImmutableStack<T>
reverse()
int
size()
boolean
topMatches(ImmutableStack<T> other)
String
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 Detail
-
ImmutableStack
protected ImmutableStack(T[] entries)
-
-
Method Detail
-
getMaxSize
public static int getMaxSize()
-
emptyStack
public static final <T> ImmutableStack<T> emptyStack()
-
push
public ImmutableStack<T> push(T entry)
-
makeInternalArray
protected T[] makeInternalArray(int size)
-
makeStack
protected ImmutableStack<T> makeStack(T[] tmpEntries)
-
peek
public T peek()
- Returns:
- the element on the top of the stack
- Throws:
EmptyStackException
- if stack is empty
-
pop
public ImmutableStack<T> pop()
- Throws:
EmptyStackException
- if stack is empty
-
isEmpty
public boolean isEmpty()
-
size
public int size()
-
get
public T get(int i)
-
contains
public boolean contains(T entry)
-
topMatches
public boolean topMatches(ImmutableStack<T> other) throws IllegalArgumentException
- Returns:
true
iff other.size() = k, k <= this.size(), and the top k elements of this equal other- Throws:
IllegalArgumentException
- if other == null
-
reverse
public ImmutableStack<T> reverse()
-
popAll
public ImmutableStack<T> popAll(ImmutableStack<T> other)
-
pushAll
public ImmutableStack<T> pushAll(ImmutableStack<T> other)
-
replaceTop
public ImmutableStack<T> replaceTop(T t)
return a new stack with the top replaced with t- Throws:
EmptyStackException
-
-