|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkodkod.util.collections.Stack<T>
public abstract class Stack<T>
Represents a last-in-first-out (LIFO) stack of objects. The usual push and pop operations are provided, as well as a method to peek at the top item on the stack, a method to test for whether the stack is empty, and an iterator over the elements in the stack (that does not support removal). When a stack is first created, it contains no items.
size: int |
elems: [0..size)->one T |
Method Summary | |
---|---|
abstract boolean |
empty()
Returns true if the stack is empty; otherwise returns false. |
boolean |
equals(java.lang.Object o)
Returns true if o is a stack containing the same elements as this stack, in the same order. |
int |
hashCode()
Returns the hashcode for this stack. |
abstract java.util.Iterator<T> |
iterator()
Iterates over the items in this Stack, starting at the top of the stack and working its way down. |
abstract T |
peek()
Looks at the object at the top of this stack without removing it from the stack. |
abstract T |
pop()
Removes the object at the top of this stack and returns that object as the value of this function. |
abstract T |
push(T item)
Pushes an item onto the top of this stack and returns it. |
abstract int |
search(java.lang.Object o)
Returns the 1-based position where an object is on this stack. |
abstract int |
size()
Returns the size of this stack. |
java.lang.String |
toString()
Returns a string represention of this stack. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public abstract int size()
public abstract T push(T item)
this.size' = this.size + 1 && this.elems'[0] = item &&
all i: [0..this.size) | this.elems'[i+1] = this.elems[i] |
public abstract T pop()
java.util.EmptyStackException
- - no this.elemsthis.size' = this.size - 1 &&
all i: [1..this.size) | this.elems'[i-1] = this.elems[i] |
public abstract T peek()
java.util.EmptyStackException
- - no this.elemspublic abstract int search(java.lang.Object o)
public abstract boolean empty()
public abstract java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |