|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpt.ua.base.Listable<K>
pt.ua.base.AssociativeArray<K,E>
public abstract class AssociativeArray<K,E>
Generic associative array module.
invariant: Listable
This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.
Constructor Summary | |
---|---|
AssociativeArray()
|
Method Summary | |
---|---|
abstract void |
clear()
Empties the associative array. |
void |
copy(AssociativeArray<K,E> other)
Copies an associative array to this associative array (deep copy). |
abstract AssociativeArray<K,E> |
deepClone()
Clones current list. |
abstract boolean |
exists(K key)
Checks if key exists in the associative array. |
abstract E |
get(K key)
Gets the element value associated with value key . |
boolean |
isFull()
Queries the list fullness. |
boolean |
isLimited()
Checks if list is unbounded. |
abstract Array<K> |
keysToArray()
Extracts all keys to an array. |
abstract ImmutableList<K> |
keysToList()
Extracts all keys to an immutable list. |
int |
maxSize()
The list maximum number of elements. |
abstract void |
remove(K key)
Removes key and its associated element value from the array. |
abstract void |
set(K key,
E elem)
Associates value elem with value key . |
Array<K> |
toArray()
Extracts all the elements of the list. |
ImmutableList<K> |
toList()
Extracts all the elements of the list. |
Methods inherited from class pt.ua.base.Listable |
---|
isEmpty, size |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AssociativeArray()
Method Detail |
---|
public boolean isLimited()
Listable
isLimited
in class Listable<K>
true
if list is unbounded, false
otherwisepublic int maxSize()
Listable
requires: isLimited()
maxSize
in class Listable<K>
public void copy(AssociativeArray<K,E> other)
requires: other != null
other
- the associative array to copy frompublic abstract AssociativeArray<K,E> deepClone()
Listable
ensures: \result.size() == size()
deepClone
in class Listable<K>
public abstract void set(K key, E elem)
elem
with value key
.
If key did not exist, adds a new association, otherwise attaches existing
key to a new element value.
requires: key != null
ensures: exists(key)
ensures: get(key) == elem
ensures: \old(exists(key)) ==> (size() == \old(size()))
ensures: \old(!exists(key)) ==> (size() == \old(size()) + 1)
key
- the keyelem
- the elementpublic abstract E get(K key)
key
.
requires: key != null
requires: exists(key)
key
- the key
public abstract void remove(K key)
key
and its associated element value from the array.
requires: key != null
requires: exists(key)
ensures: !exists(key)
ensures: size() == \old(size()) - 1
key
- the key to be removedpublic abstract boolean exists(K key)
key
exists in the associative array.
true
if key exists, false
otherwisepublic boolean isFull()
Listable
isFull
in class Listable<K>
true
if list is full, false
otherwisepublic abstract Array<K> keysToArray()
toArray()
.
ensures: \result.size() == size()
public Array<K> toArray()
Listable
ensures: \result.size() == size()
toArray
in class Listable<K>
public abstract ImmutableList<K> keysToList()
toList()
.
ensures: \result.size == size()
public ImmutableList<K> toList()
Listable
ensures: \result.size == size()
toList
in class Listable<K>
public abstract void clear()
ensures: isEmpty()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |