|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,V>
ptolemy.actor.gt.data.TwoWayHashMap<K,V>
K - The key type.V - The value type.public class TwoWayHashMap<K,V>
A hash map that has one-to-one relationship between keys and values. With the implementation of two hash maps instead of one, the lookup for keys with values is just as efficient as the lookup for values with keys.
| Red (tfeng) |
| Yellow (tfeng) |
| Field Summary | |
|---|---|
private java.util.HashMap<V,K> |
_reverseMap
The reverse hash map that maps values back to keys. |
| Constructor Summary | |
|---|---|
TwoWayHashMap()
Construct an empty two-way hash map. |
|
TwoWayHashMap(int initialCapacity)
Construct an empty two-way hash map with an initial capacity. |
|
TwoWayHashMap(int initialCapacity,
float loadFactor)
Construct an empty two-way hash map with an initial capacity and a load factor. |
|
TwoWayHashMap(java.util.Map<? extends K,? extends V> map)
Construct a two-way hash map with the given hash map, which must have a one-to-one relationship between elements. |
|
| Method Summary | |
|---|---|
void |
clear()
Clear this two-way hash map. |
java.lang.Object |
clone()
Clone this two-way hash map and return the clone. |
boolean |
containsValue(java.lang.Object value)
Test whether this two-way hash map contains the given value. |
K |
getKey(java.lang.Object value)
Given a value, return the corresponding key in this two-way hash map. |
V |
put(K key,
V value)
Put a value into this two-way hash map and associate it with a key. |
V |
remove(java.lang.Object key)
Remove the value associated with the given key. |
java.util.Set<V> |
values()
Return a set containing all the values in this two-way hash map. |
| Methods inherited from class java.util.HashMap |
|---|
containsKey, entrySet, get, isEmpty, keySet, putAll, size |
| 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 |
| Field Detail |
|---|
private java.util.HashMap<V,K> _reverseMap
| Constructor Detail |
|---|
public TwoWayHashMap()
public TwoWayHashMap(java.util.Map<? extends K,? extends V> map)
map - The hash map.public TwoWayHashMap(int initialCapacity)
initialCapacity - The initial capacity.
public TwoWayHashMap(int initialCapacity,
float loadFactor)
initialCapacity - The initial capacity.loadFactor - The load factor.| Method Detail |
|---|
public void clear()
clear in interface java.util.Map<K,V>clear in class java.util.HashMap<K,V>public java.lang.Object clone()
clone in class java.util.HashMap<K,V>public boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Map<K,V>containsValue in class java.util.HashMap<K,V>value - The value.
public K getKey(java.lang.Object value)
value - The value.
public V put(K key,
V value)
put in interface java.util.Map<K,V>put in class java.util.HashMap<K,V>key - The key.value - The value.
public V remove(java.lang.Object key)
remove in interface java.util.Map<K,V>remove in class java.util.HashMap<K,V>key - The key.
public java.util.Set<V> values()
values in interface java.util.Map<K,V>values in class java.util.HashMap<K,V>
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||