pt.ua.base
Class Listable<T>

java.lang.Object
  extended by pt.ua.base.Listable<T>
Direct Known Subclasses:
AssociativeArray, Indexable

public abstract class Listable<T>
extends java.lang.Object

Generic listable list.

invariant: size() >= 0
invariant: isEmpty() <==> (size() == 0)

This class follows DbC(tm) methodology. Where possible, contracts are implement with JML and native's Java assert.

Author:
Miguel Oliveira e Silva (mos@ua.pt)

Constructor Summary
Listable()
           
 
Method Summary
abstract  Listable<T> deepClone()
          Clones current list.
 boolean isEmpty()
          Queries the list emptiness.
abstract  boolean isFull()
          Queries the list fullness.
abstract  boolean isLimited()
          Checks if list is unbounded.
abstract  int maxSize()
          The list maximum number of elements.
abstract  int size()
          The list total number of elements.
abstract  Array<T> toArray()
          Extracts all the elements of the list.
abstract  ImmutableList<T> toList()
          Extracts all the elements of the list.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Listable

public Listable()
Method Detail

size

public abstract int size()
The list total number of elements.

Returns:
list's size

isEmpty

public boolean isEmpty()
Queries the list emptiness.

Returns:
true if list is empty, false otherwise

isFull

public abstract boolean isFull()
Queries the list fullness.

Returns:
true if list is full, false otherwise

isLimited

public abstract boolean isLimited()
Checks if list is unbounded.

Returns:
true if list is unbounded, false otherwise

maxSize

public abstract int maxSize()
The list maximum number of elements.

requires: isLimited()

Returns:
list's size

deepClone

public abstract Listable<T> deepClone()
Clones current list.

ensures: \result.size() == size()

Returns:
a deep clone of current list

toList

public abstract ImmutableList<T> toList()
Extracts all the elements of the list.

ensures: \result.size == size()

Returns:
an immutable list with all the list's elements

toArray

public abstract Array<T> toArray()
Extracts all the elements of the list.

ensures: \result.size() == size()

Returns:
an array with all the list's elements