jrunx.util
Class OrderedHashMap
java.lang.Object
|
+--java.util.AbstractMap
|
+--java.util.HashMap
|
+--jrunx.util.OrderedHashMap
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.Map, java.io.Serializable
- public class OrderedHashMap
- extends java.util.HashMap
Hashtable that maintains the order in which objects are inserted.
This object is useful for enumerating through keys in the order
that they were inserted.
- See Also:
- Serialized Form
| Inner classes inherited from class java.util.Map |
java.util.Map.Entry |
|
Method Summary |
void |
clear()
Clears this hashtable so that it contains no keys. |
java.lang.Object |
get(int index)
Get the element at the specified index. |
java.util.Iterator |
iterator()
Returns the ordered set of elements. |
java.util.Iterator |
keys()
Returns the ordered set of keys. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Insert an object into the table using the specified key. |
java.lang.Object |
remove(java.lang.Object key)
Remove the object associated with the specified key. |
| Methods inherited from class java.util.HashMap |
clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, size, values |
| Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
equals, hashCode |
OrderedHashMap
public OrderedHashMap()
iterator
public java.util.Iterator iterator()
- Returns the ordered set of elements.
Elements are ordered by the insertion order of their keys.
The top-most object is the oldest inserted element.
The bottom-most object is the most recently inserted element.
If an element has been hashed multiple times using different
keys, then it will show up in the the enumeration once for each
key.
get
public java.lang.Object get(int index)
- Get the element at the specified index.
Note: - this returns the element object, not the key.
- Returns:
- the element at the specified index.
keys
public java.util.Iterator keys()
- Returns the ordered set of keys.
Keys are ordered by their insertion order.
The top-most object is the oldest inserted key.
The bottom-most object is the most recently inserted key.
put
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
- Insert an object into the table using the specified key.
If this key already exists in the table, it will be
removed and then reinserted at the bottom of the ordered list.
- Overrides:
put in class java.util.HashMap
remove
public java.lang.Object remove(java.lang.Object key)
- Remove the object associated with the specified key.
- Overrides:
remove in class java.util.HashMap
clear
public void clear()
- Clears this hashtable so that it contains no keys.
- Overrides:
clear in class java.util.HashMap
Copyright � 2002 Macromedia Corporation. All Rights Reserved.