jds.collection
Class MapAdapter

java.lang.Object
  |
  +--jds.collection.MapAdapter

public class MapAdapter
extends java.lang.Object
implements Map

MapAdapter - collection of key/value pairs; for use with book Classic Data Structures in Java by Timothy A Budd, published by Addison-Wesley, 2001.

See Also:
Collection, Serialized Form

Constructor Summary
MapAdapter(Bag aBag)
          initialize newly created Map
MapAdapter(Bag aBag, java.util.Comparator t)
          initialize newly created Map
 
Method Summary
 boolean containsKey(java.lang.Object key)
          see if collection contains element with given key
 java.util.Enumeration elements()
          Yields enumerator for collection
 java.lang.Object get(java.lang.Object key)
          return object stored under given key
 boolean isEmpty()
          Determines whether the collection is empty
 void removeKey(java.lang.Object key)
          remove element with given key
 void set(java.lang.Object key, java.lang.Object newValue)
          establish new key/value connection, or replace value associated with key
 int size()
          Determines number of elements in collection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapAdapter

public MapAdapter(Bag aBag)
initialize newly created Map
Parameters:
aBag - the set to hold the underlying data values

MapAdapter

public MapAdapter(Bag aBag,
                  java.util.Comparator t)
initialize newly created Map
Parameters:
aBag - the set to hold the underlying data values
t - the comparator object used to order map keys
Method Detail

isEmpty

public boolean isEmpty()
Determines whether the collection is empty
Returns:
true if the collection is empty

size

public int size()
Determines number of elements in collection
Returns:
number of elements in collection as integer

elements

public java.util.Enumeration elements()
Yields enumerator for collection
Returns:
an Enumeration that will yield the elements of the collection
See Also:
Enumeration

containsKey

public boolean containsKey(java.lang.Object key)
see if collection contains element with given key
Specified by:
containsKey in interface Map
Parameters:
key - index for element to be tested
Returns:
true if collection has entry with given key

get

public java.lang.Object get(java.lang.Object key)
return object stored under given key
Specified by:
get in interface Map
Parameters:
key - index for element to be accessed
Returns:
value of object stored with given key
Throws:
java.util.NoSuchElementException - no value with given key

removeKey

public void removeKey(java.lang.Object key)
remove element with given key
Specified by:
removeKey in interface Map
Parameters:
key - index for element to be removed
Throws:
java.util.NoSuchElementException - no value with given key

set

public void set(java.lang.Object key,
                java.lang.Object newValue)
establish new key/value connection, or replace value associated with key
Specified by:
set in interface Map
Parameters:
key - index for element to be tested
value - element to be associated with key