|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpt.ua.base.Listable<T>
pt.ua.base.Indexable<T>
pt.ua.base.Stack<T>
public abstract class Stack<T>
Generic stack module.
invariant: !isEmpty() ==> (top() == itemAt(0))
invariant: Indexable
This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.
Constructor Summary | |
---|---|
Stack()
|
Method Summary | |
---|---|
abstract void |
clear()
Empties the stack. |
void |
copy(Stack<T> other)
Copies a stack to this stack (deep copy). |
abstract Stack<T> |
deepClone()
Clones current list. |
abstract void |
pop()
Removes the top element from the stack. |
abstract void |
push(T e)
Adds an element to the top of the stack. |
T |
top()
Without changing the stack, returns its top element. |
Methods inherited from class pt.ua.base.Indexable |
---|
headList, itemAt, subList, tailList, toArray, toList, toString |
Methods inherited from class pt.ua.base.Listable |
---|
isEmpty, isFull, isLimited, maxSize, size |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Stack()
Method Detail |
---|
public void copy(Stack<T> other)
requires: other != null
requires: !isLimited() || maxSize() >= other.size()
other
- the stack to copy frompublic abstract Stack<T> deepClone()
Listable
ensures: \result.size() == size()
deepClone
in class Indexable<T>
public abstract void push(T e)
requires: !isFull()
ensures: !isEmpty() && top() == e
ensures: size() == \old(size()) + 1
ensures: tailList(1).equals(\old(tailList(0)))
e
- the element to pushpublic abstract void pop()
requires: !isEmpty()
ensures: !isFull()
ensures: size() == \old(size()) - 1
ensures: tailList(0).equals(\old(tailList(1)))
public T top()
requires: !isEmpty()
public abstract void clear()
ensures: isEmpty()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |