FlexOr.container
Interface Container

All Superinterfaces:
java.lang.Cloneable
All Known Subinterfaces:
Sequence
All Known Implementing Classes:
BinaryTree, CircularArray, DLList, Heap, OrderedBinaryTree, PriorityQueue, Queue, SLList, Stack

public interface Container
extends java.lang.Cloneable

A container can hold any collection of Objects.

Version:
1.0 1999 Jan 15
Author:
Gunnar Gotshalks

Method Summary
 void add(java.lang.Object obj)
          Adds obj at the default location.
 java.lang.Object clone()
          Return a copy of the container that points to the same objects as in the original container.
 boolean contains(java.lang.Object obj)
          Determines whether an element is in the container.
 java.util.Enumeration<java.lang.Object> elements()
          Returns an enumerator over the whole container.
 boolean equals(java.lang.Object container)
          Check for equality of contents of two containers.
 boolean isEmpty()
          Check if the container is empty.
 boolean isFull()
          Check if the container is full.
 java.lang.Object remove()
          Remove the first element based on a standard enumeration of the container contents.
 void removeAll()
          Empty the container.
 int size()
          Returns the number of elements in the container.
 java.lang.String toString()
          Return a string representation of the contents of the container.
 

Method Detail

contains

boolean contains(java.lang.Object obj)
Determines whether an element is in the container.

Requires: True
Ensures: contains(obj) => result = true
            not contains(obj) => result = false


elements

java.util.Enumeration<java.lang.Object> elements()
Returns an enumerator over the whole container.


isEmpty

boolean isEmpty()
Check if the container is empty.

Requires: True
Ensures: result = (size = 0)


isFull

boolean isFull()
Check if the container is full.

Requires: True
Ensures: result = (size = capacity)


size

int size()
Returns the number of elements in the container.

Requires: True
Ensures: result = size


add

void add(java.lang.Object obj)
Adds obj at the default location.

Requires: size < capacity
Ensures: contains(obj) = true
                size = old size + 1

Throws:
ContainerFullException - if container already contains capacity elements for finite size containers.

removeAll

void removeAll()
Empty the container.

Requires: True
Ensures: size = 0


remove

java.lang.Object remove()
Remove the first element based on a standard enumeration of the container contents.

Requires: size > 0
Ensures: size = old size -1

Throws:
ContainerEmptyException - if removing from an empty container.

clone

java.lang.Object clone()
Return a copy of the container that points to the same objects as in the original container. Part way between a shallow and deep copy. This is equivalent to how a Vector is cloned.

Requires: True
Ensures: result = copy of container


toString

java.lang.String toString()
Return a string representation of the contents of the container.

Requires: True
Ensures: result = string representation of contents

Overrides:
toString in class java.lang.Object

equals

boolean equals(java.lang.Object container)
Check for equality of contents of two containers. By equality we mean an equal sequence of elements as returned by the Enumerator for each sequence.

Requires: True
Ensures: result = true => container contents are equal
                result = false => container contents are not equal

Overrides:
equals in class java.lang.Object