|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjpaul.DataStructs.NoCompTreeMap<K,V>
public class NoCompTreeMap<K,V>
NoCompTreeMap is tree map that does not require any
used-defined Comparator. Instead, the tree is ordered
by the relative ordering between the haashcodes of the keys. The
implementation is able to cope with the situation when two
non-equal keys have the same hashcode: intuitively, the key that is
put first in the map is considered lower than the other one.
For the curious programmer, when we add a new mapping, if the key to add has the same hashcode as the key from a tree node, we decend into the right subtree (unless the keys are equal). This means that if two many keys have the same hashcode, the tree can degenerate into a list. Still, we think this is unlikely to happen frequently in practice; in practice, we expect the complexity of operations to be more or less logarithmic in the size of the tree.
This map is useful to use in programs with many small maps or when coming out with a total ordering between elements is difficult (or the programmer is too lazy to think about such an order).
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
java.util.Map.Entry<K,V> |
| Constructor Summary | |
|---|---|
NoCompTreeMap()
Creates a NoCompTreeMap. |
|
NoCompTreeMap(java.util.Map<? extends K,? extends V> map)
Creates a NoCompTreeMap with the same mappings as the
given map. |
|
| Method Summary | |
|---|---|
void |
clear()
|
NoCompTreeMap<K,V> |
clone()
|
boolean |
containsKey(java.lang.Object key)
|
boolean |
containsValue(java.lang.Object value)
Unsupported yet. |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet()
Returns an unmodifiable set view of the map entries. |
boolean |
equals(java.lang.Object o)
|
V |
get(java.lang.Object key)
|
int |
hashCode()
|
boolean |
isEmpty()
|
java.util.Set<K> |
keySet()
Returns an unmodifiable set view of the keys contained in this map. |
V |
put(K key,
V value)
Associates the specified value with the specified key in this map. |
void |
putAll(java.util.Map<? extends K,? extends V> map)
Copies all of the mappings from the specified map to this map. |
V |
remove(java.lang.Object key)
Removes the mapping previously attached to key. |
int |
size()
|
java.lang.String |
toString()
|
java.util.Collection<V> |
values()
Returns an unmodifiable collection view of the values from this map. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public NoCompTreeMap()
NoCompTreeMap.
public NoCompTreeMap(java.util.Map<? extends K,? extends V> map)
NoCompTreeMap with the same mappings as the
given map.
| Method Detail |
|---|
public final int size()
size in interface java.util.Map<K,V>public final boolean isEmpty()
isEmpty in interface java.util.Map<K,V>public final boolean containsKey(java.lang.Object key)
containsKey in interface java.util.Map<K,V>public final boolean containsValue(java.lang.Object value)
containsValue in interface java.util.Map<K,V>public V get(java.lang.Object key)
get in interface java.util.Map<K,V>
public final V put(K key,
V value)
put in interface java.util.Map<K,V>public final V remove(java.lang.Object key)
key.
Returns the old mapping if any, or null otherwise.
remove in interface java.util.Map<K,V>public final void putAll(java.util.Map<? extends K,? extends V> map)
putAll in interface java.util.Map<K,V>public final void clear()
clear in interface java.util.Map<K,V>public final java.util.Collection<V> values()
values in interface java.util.Map<K,V>public final java.util.Set<java.util.Map.Entry<K,V>> entrySet()
entrySet in interface java.util.Map<K,V>public final java.util.Set<K> keySet()
keySet in interface java.util.Map<K,V>public NoCompTreeMap<K,V> clone()
clone in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in interface java.util.Map<K,V>equals in class java.lang.Objectpublic int hashCode()
hashCode in interface java.util.Map<K,V>hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||