|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpt.ua.base.Listable<T>
pt.ua.base.Indexable<T>
pt.ua.base.Queue<T>
public abstract class Queue<T>
Generic queue module.
invariant: !isEmpty() ==> (peek() == itemAt(0))
invariant: Indexable
This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.
Constructor Summary | |
---|---|
Queue()
|
Method Summary | |
---|---|
abstract void |
clear()
Empties the queue. |
void |
copy(Queue<T> other)
Copies a queue to this queue (deep copy). |
abstract Queue<T> |
deepClone()
Clones current list. |
abstract void |
in(T e)
Adds an element to the tail of the queue. |
abstract void |
out()
Removes the head element from the queue. |
T |
peek()
Without changing the queue, returns its head element. |
T |
peekIn()
Without changing the queue, returns its tail 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 Queue()
Method Detail |
---|
public void copy(Queue<T> other)
requires: other != null
requires: !isLimited() || maxSize() >= other.size()
other
- the queue to copy frompublic abstract Queue<T> deepClone()
Listable
ensures: \result.size() == size()
deepClone
in class Indexable<T>
public abstract void in(T e)
requires: !isFull()
ensures: !isEmpty() && itemAt(size()-1) == e
ensures: size() == \old(size()) + 1
ensures: headList(size()-1).equals(\old(toList()))
e
- the element to enqueuepublic abstract void out()
requires: !isEmpty()
ensures: !isFull()
ensures: size() == \old(size()) - 1
ensures: toList().equals(\old(tailList(1)))
public T peek()
requires: !isEmpty()
public T peekIn()
requires: !isEmpty()
public abstract void clear()
ensures: isEmpty()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |