|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttl.lin.data.map.HMapKL<K>
K - the type of keys maintained by this mappublic class HMapKL<K>
Hash-based implementation of the MapKL interface. MapKL is
a specialized variant the standard Java Map interface, except that
the values are hard coded as floats for efficiency reasons (keys can be
arbitrary objects). This implementation was adapted from HashMap
version 1.73, 03/13/07. See this
benchmark for an efficiency comparison.
| Field Summary |
|---|
| Fields inherited from interface tl.lin.data.map.MapKL |
|---|
DEFAULT_VALUE |
| Constructor Summary | |
|---|---|
HMapKL()
Constructs an empty HMapKL with the default initial capacity (1024) and the default load factor (0.75). |
|
HMapKL(int initialCapacity)
Constructs an empty HMapKL with the specified initial capacity and the default load factor (0.75). |
|
HMapKL(int initialCapacity,
float loadFactor)
Constructs an empty HMapKL with the specified initial capacity and load factor. |
|
HMapKL(MapKL<? extends K> m)
Constructs a new HMapKL with the same mappings as the specified MapKL. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all of the mappings from this map. |
Object |
clone()
Returns a shallow copy of this HMapKL instance: the keys and values themselves are not cloned. |
boolean |
containsKey(K key)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(long value)
Returns true if this map contains one or more mappings with the specified value. |
Set<MapKL.Entry<K>> |
entrySet()
Returns a Set view of the mappings contained in this map. |
long |
get(K key)
Returns the value to which the specified key is mapped, or throws NoSuchElementException if this map contains no mapping for the key. |
void |
increment(K key)
Increments the key. |
void |
increment(K key,
long value)
Increments the key by some value. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
Set<K> |
keySet()
Returns a Set view of the keys contained in this map. |
long |
put(K key,
long value)
Associates the specified value with the specified key in this map. |
void |
putAll(MapKL<? extends K> m)
Copies all of the mappings from the specified map to this map. |
long |
remove(K key)
Removes the mapping for a key from this map if it is present. |
int |
size()
Returns the number of key-value mappings in this map. |
String |
toString()
|
Collection<Long> |
values()
Returns a Collection view of the values contained in this map. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface tl.lin.data.map.MapKL |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public HMapKL(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacityloadFactor - the load factor
IllegalArgumentException - if the initial capacity is negative or the load factor is
nonpositivepublic HMapKL(int initialCapacity)
initialCapacity - the initial capacity.
IllegalArgumentException - if the initial capacity is negative.public HMapKL()
public HMapKL(MapKL<? extends K> m)
m - the map whose mappings are to be placed in this map
NullPointerException - if the specified map is null| Method Detail |
|---|
public int size()
MapKL
size in interface MapKL<K>public boolean isEmpty()
MapKL
isEmpty in interface MapKL<K>public long get(K key)
MapKLNoSuchElementException if this map contains no mapping for the key.
get in interface MapKL<K>key - the key whose associated value is to be returned
public boolean containsKey(K key)
MapKL
containsKey in interface MapKL<K>key - key whose presence in this map is to be tested
public void increment(K key)
key - key to increment
public void increment(K key,
long value)
key - key to incrementvalue - increment value
public long put(K key,
long value)
MapKL
put in interface MapKL<K>key - key with which the specified value is to be associatedvalue - value to be associated with the specified key
public void putAll(MapKL<? extends K> m)
MapKL
putAll in interface MapKL<K>m - mappings to be stored in this mappublic long remove(K key)
MapKL
remove in interface MapKL<K>key - key whose mapping is to be removed from the mappublic void clear()
MapKL
clear in interface MapKL<K>public boolean containsValue(long value)
MapKL
containsValue in interface MapKL<K>value - value whose presence in this map is to be tested
public Object clone()
clone in class Objectpublic Set<K> keySet()
MapKLSet view of the keys contained in this map. The set is backed by the map, so
changes to the map are reflected in the set, and vice-versa.
keySet in interface MapKL<K>public Collection<Long> values()
MapKLCollection view of the values contained in this map. Note that this is a
inefficient operation since it triggers autoboxing of the long values, which is exactly what
this implementation is trying to avoid. Unlike a standard Java Map, values in the
backing map cannot be altered with this collection view.
values in interface MapKL<K>public Set<MapKL.Entry<K>> entrySet()
MapKLSet view of the mappings contained in this map. The set is backed by the map,
so changes to the map are reflected in the set, and vice-versa.
entrySet in interface MapKL<K>public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||