Class OrderedHashtable

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--OrderedHashtable
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class OrderedHashtable
extends java.util.Hashtable

The class `OrderedHashtable' is a subclass of Hashtable that records the order of keys (by overriding the methods put and remove), and adds a method keyListIterator to return an iterator over the keys in the order in which they were put.

See Also:
Serialized Form

Inner classes inherited from class java.util.Map
java.util.Map.Entry
 
Constructor Summary
OrderedHashtable()
          Constructs an empty ordered hashtable.
 
Method Summary
 java.util.ListIterator keyListIterator()
          Returns an iterator over the keys in this hashtable, in the order that they were put.
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtable.
 java.lang.Object remove(java.lang.Object key)
          Removes the key (and its corresponding value) from this hashtable.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OrderedHashtable

public OrderedHashtable()
Constructs an empty ordered hashtable.
Method Detail

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Maps the specified key to the specified value in this hashtable. Neither the key nor the value can be null. This method overrides put in class Hashtable, and records the order in which keys are put.
Overrides:
put in class java.util.Hashtable
Parameters:
key - the hashtable key.
value - the value.
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one.

remove

public java.lang.Object remove(java.lang.Object key)
Removes the key (and its corresponding value) from this hashtable. This method does nothing if the key is not in the hashtable. This method overrides remove in class Hashtable, deleting the key from the list of keys.
Overrides:
remove in class java.util.Hashtable
Parameters:
key - the key that needs to be removed.
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.

keyListIterator

public java.util.ListIterator keyListIterator()
Returns an iterator over the keys in this hashtable, in the order that they were put. (If a key was filled twice, its position in the iterator is determined by the first time it was put.) This method clones the list of keys to avoid the problems of concurrent modification (the hashtable being modified while the keys are being iterated over).
Returns:
An iterator over the keys in this frame.