gshute.util
Interface Table

All Known Implementing Classes:
ListTable

public abstract interface Table

A Table is a collection that supports random access of data by key. For this interface, the key-data association is determined when data is added. A client can

This method has two parameters, one to specify the data and one to specify the key that will be used to access the data. A closely related class, Dictionary, should be used when the key is implicit in the data.

A client can

All of these methods have a parameter to specify the key. The dataFor() and remove() methods throw IllegalArgumentException exceptions if there is no data for the specified key. The client should usually call isKey() to check for the key prior to calling dataFor() or remove().

A client can also


Inner Class Summary
static interface Table.Entry
          A Table.Entry is an entry in a table.
 
Method Summary
 void add(java.lang.Object k, java.lang.Object dat)
          tbl.add(k, dat) adds an entry with data dat and key k to tbl.
 void clear()
          tbl.clear() removes all entries from tbl.
 java.lang.Object data(java.lang.Object k)
          tbl.data(k) returns the data for key k in tbl.
 boolean isKey(java.lang.Object k)
          tbl.isKey(k) returns true if there is an entry with key k in tbl.
 java.util.Iterator iterator()
          tbl.iterator() returns an iterator for all of the entries in tbl.
 java.util.Iterator iterator(java.lang.Object kLo)
          tbl.iterator(Object kLo) returns an iterator for the entries in tbl whose key is at least kLo.
 java.util.Iterator iterator(java.lang.Object kLo, java.lang.Object kHi)
          tbl.iterator(Object kLo, Object kHi) returns an iterator for the entries in tbl whose key is at least kLo and less than kHi.
 void remove(java.lang.Object k)
          tbl.remove(k) removes the entry for key k from tbl.
 int size()
          tbl.size() returns the number of entries in tbl.
 

Method Detail

isKey

public boolean isKey(java.lang.Object k)
tbl.isKey(k) returns true if there is an entry with key k in tbl.

add

public void add(java.lang.Object k,
                java.lang.Object dat)
tbl.add(k, dat) adds an entry with data dat and key k to tbl.

Precondition: tbl.isKey(k) is false.


data

public java.lang.Object data(java.lang.Object k)
tbl.data(k) returns the data for key k in tbl.

Precondition: tbl.isKey(k) is true.


remove

public void remove(java.lang.Object k)
tbl.remove(k) removes the entry for key k from tbl.

Precondition: tbl.isKey(k) is true.


size

public int size()
tbl.size() returns the number of entries in tbl.

clear

public void clear()
tbl.clear() removes all entries from tbl.

iterator

public java.util.Iterator iterator()
tbl.iterator() returns an iterator for all of the entries in tbl.

iterator

public java.util.Iterator iterator(java.lang.Object kLo)
tbl.iterator(Object kLo) returns an iterator for the entries in tbl whose key is at least kLo.

iterator

public java.util.Iterator iterator(java.lang.Object kLo,
                                   java.lang.Object kHi)
tbl.iterator(Object kLo, Object kHi) returns an iterator for the entries in tbl whose key is at least kLo and less than kHi.