gshute.util
Interface RandomAccess


public abstract interface RandomAccess

The RandomAccess interface defines the common methods of the Table and Dictionary interfaces. 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. A client should usually call isKey() to check for the key prior to calling dataFor() or remove().

A client can also

Methods for adding entries are defined in the Table and Dictionary intefaces.


Method Summary
 void clear()
          ra.clear() removes all entries from ra.
 java.lang.Object dataFor(java.lang.Object k)
          ra.dataFor(k) returns the data for key k in ra.
 boolean isKey(java.lang.Object k)
          ra.isKey(k) returns true if there is an entry with key k in ra.
 java.util.Iterator iterator()
          ra.iterator() returns an iterator for all of the entries in ra.
 java.util.Iterator iterator(java.lang.Object kLo)
          ra.iterator(Object kLo) returns an iterator for the entries in ra whose key is at least kLo.
 java.util.Iterator iterator(java.lang.Object kLo, java.lang.Object kHi)
          ra.iterator(Object kLo, Object kHi) returns an iterator for the entries in ra whose key is at least kLo and less than kHi.
 void remove(java.lang.Object k)
          ra.remove(k) removes the entry for key k from ra.
 int size()
          ra.size() returns the number of entries in ra.
 

Method Detail

isKey

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

dataFor

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

Precondition: ra.isKey(k) is true.


remove

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

Precondition: ra.isKey(k) is true.


size

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

clear

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

iterator

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

iterator

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

iterator

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