Class next.util.MutableHashtable

CLASS DESCRIPTION

Extends:
next.util.ImmutableHashtable

The MutableHashtable class declares the programmatic interface to objects that manage mutable associations of keys and values. With its two efficient primitive methods-put and removeObjectsForKeys-this class adds modification operations to the basic operations it inherits from ImmutableHashtable.

The other methods declared here operate by invoking one or both of these primitives. The non-primitive methods provide convenient ways of adding or removing multiple entries at a time.


CONSTRUCTORS

MutableHashtable

public MutableHashtable()
public MutableHashtable(int numItems)
public MutableHashtable(java.lang.Object[] keys, java.lang.Object[] objects)
public MutableHashtable(java.util.Hashtable aHashtable)

Creates and returns a MutableHashtable.

If no parameters are supplied, the returned hashtable will be empty. This is used primarily by mutable subclasses of MutableHashtable.

If you supply numItems, the returned MutableHashtable has enough allocated memory to hold numItems entries. MutableHashtables allocate additional memory as needed, so numItems simply establishes the object's initial capacity.

If you supply both keys and objects, the returned MutableHashtable is initialized with entries constructed from the contents of the keys and objects arrays. This method steps through the keys and objects arrays, creating entries in the new MutableHashtable as it goes. An exception is raised if the objects and keys arrays do not have the same number of elements.

If you supply aHashtable, the returned MutableHashtable will be initialized with the contents of the specified Java Hashtable.


METHODS

addEntries

public void addEntries(next.util.ImmutableHashtable anImmutableHashtable)

Adds the entries from anImmutableHashtable to the receiver.


clear

public void clear()

Empties the MutableHashtable of its entries. This method simply invokes removeAllObjects.


put

public java.lang.Object put(java.lang.Object aKey, java.lang.Object anObject)

Adds an entry to the receiver, consisting of aKey and its corresponding value object anObject. A NullPointerException is raised if anObject is nil.


removeAllObjects

public void removeAllObjects()

Empties the MutableHashtable of its entries.


removeObjectsForKeys

public void removeObjectsForKeys(next.util.ImmutableVector keys)

Removes one or more entries from the receiver. The entries are identified by the keys in keys.


replace

public java.lang.Object replace(java.lang.Object aKey, java.lang.Object anObject)

Replaces the value in the receiver corresponding to aKey with anObject.


setEntries

public void setEntries(next.util.ImmutableHashtable anImmutableHashtable)

Sets the receiver to entries in anImmutableHashtable. setEntries does this by removing all entries from the receiver (with removeAllObjects) then adding each entry from anImmutableHashtable into the receiver.