|
||||||||
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.Queue<T>
pt.ua.base.ArrayedQueue<T>
public class ArrayedQueue<T>
Queue module implemented with an array.
invariant: Queue
This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.
Constructor Summary | |
---|---|
ArrayedQueue()
Creates an unbounded queue. |
|
ArrayedQueue(int maxSize)
Creates an bounded queue limited to maxSize elements. |
Method Summary | |
---|---|
void |
clear()
Empties the queue. |
Queue<T> |
deepClone()
Clones current list. |
void |
in(T e)
Adds an element to the tail of the queue. |
boolean |
isFull()
Queries the list fullness. |
boolean |
isLimited()
Checks if list is unbounded. |
T |
itemAt(int idx)
Returns the element of the list at the idx position. |
int |
maxSize()
The list maximum number of elements. |
void |
out()
Removes the head element from the queue. |
int |
size()
The list total number of elements. |
Methods inherited from class pt.ua.base.Queue |
---|
copy, peek, peekIn |
Methods inherited from class pt.ua.base.Indexable |
---|
headList, subList, tailList, toArray, toList, toString |
Methods inherited from class pt.ua.base.Listable |
---|
isEmpty |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ArrayedQueue()
public ArrayedQueue(int maxSize)
maxSize
elements.
requires: maxSize >= 0
Method Detail |
---|
public boolean isLimited()
Listable
isLimited
in class Listable<T>
true
if list is unbounded, false
otherwisepublic int maxSize()
Listable
requires: isLimited()
maxSize
in class Listable<T>
public Queue<T> deepClone()
Listable
ensures: \result.size() == size()
deepClone
in class Queue<T>
public void in(T e)
Queue
requires: !isFull()
ensures: !isEmpty() && itemAt(size()-1) == e
ensures: size() == \old(size()) + 1
ensures: headList(size()-1).equals(\old(toList()))
in
in class Queue<T>
e
- the element to enqueuepublic void out()
Queue
requires: !isEmpty()
ensures: !isFull()
ensures: size() == \old(size()) - 1
ensures: toList().equals(\old(tailList(1)))
out
in class Queue<T>
public int size()
Listable
size
in class Listable<T>
public boolean isFull()
Listable
isFull
in class Listable<T>
true
if list is full, false
otherwisepublic T itemAt(int idx)
Indexable
idx
position.
requires: idx >= 0 && idx < size()
itemAt
in class Indexable<T>
idx
- the index
public void clear()
Queue
ensures: isEmpty()
clear
in class Queue<T>
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |