|
||||||||
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.Set<T>
pt.ua.base.LinkedSet<T>
public class LinkedSet<T>
Set module implemented with a linked list.
invariant: Set
This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.
Constructor Summary | |
---|---|
LinkedSet()
Creates an unbounded set. |
|
LinkedSet(int maxSize)
Creates an bounded set limited to maxSize elements. |
Method Summary | |
---|---|
void |
add(T e)
Adds an element to the set. |
void |
clear()
Empties the set. |
Set<T> |
deepClone()
Clones current list. |
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 |
remove(T e)
Removes element from the set. |
int |
size()
The list total number of elements. |
Methods inherited from class pt.ua.base.Set |
---|
copy, exists |
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 LinkedSet()
public LinkedSet(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 Set<T> deepClone()
Listable
ensures: \result.size() == size()
deepClone
in class Set<T>
public void add(T e)
Set
requires: !isFull() || exists(e)
ensures: !isEmpty() && exists(e)
ensures: \old(exists(e)) && size() == \old(size()) ||
!\old(exists(e)) && size() == \old(size()) + 1
add
in class Set<T>
e
- the element to insert in setpublic void remove(T e)
Set
requires: exists(e)
ensures: !isFull()
ensures: !exists(e)
ensures: size() == \old(size()) - 1
remove
in class Set<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()
Set
ensures: isEmpty()
clear
in class Set<T>
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |