K - the type of keys maintained by this mappublic class HMapKS<K> extends Object implements MapKS<K>, Cloneable, Serializable
MapKS 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.DEFAULT_VALUE| Constructor and Description |
|---|
HMapKS()
Constructs an empty HMapKS with the default initial capacity (1024) and the default
load factor (0.75).
|
HMapKS(int initialCapacity)
Constructs an empty HMapKS with the specified initial capacity and the default load
factor (0.75).
|
HMapKS(int initialCapacity,
float loadFactor)
Constructs an empty HMapKS with the specified initial capacity and load factor.
|
HMapKS(MapKS<? extends K> m)
Constructs a new HMapKS with the same mappings as the specified MapKS.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all of the mappings from this map.
|
Object |
clone()
Returns a shallow copy of this HMapKS 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(short value)
Returns true if this map contains one or more mappings with the specified value.
|
long |
dot(MapKS<K> m)
Computes the dot product of this map with another map.
|
Set<MapKS.Entry<K>> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
short |
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,
short 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. |
void |
plus(MapKS<K> m)
Adds values of keys from another map to this map.
|
short |
put(K key,
short value)
Associates the specified value with the specified key in this map.
|
void |
putAll(MapKS<? extends K> m)
Copies all of the mappings from the specified map to this map.
|
short |
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<Short> |
values()
Returns a
Collection view of the values contained in this map. |
public HMapKS(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacityloadFactor - the load factorIllegalArgumentException - if the initial capacity is negative or the load factor is
nonpositivepublic HMapKS(int initialCapacity)
initialCapacity - the initial capacity.IllegalArgumentException - if the initial capacity is negative.public HMapKS()
public HMapKS(MapKS<? extends K> m)
m - the map whose mappings are to be placed in this mapNullPointerException - if the specified map is nullpublic int size()
MapKSpublic boolean isEmpty()
MapKSpublic short get(K key)
MapKSNoSuchElementException if this map contains no mapping for the key.public boolean containsKey(K key)
MapKScontainsKey in interface MapKS<K>key - key whose presence in this map is to be testedpublic short put(K key, short value)
MapKSpublic void putAll(MapKS<? extends K> m)
MapKSpublic short remove(K key)
MapKSpublic void clear()
MapKSpublic boolean containsValue(short value)
MapKScontainsValue in interface MapKS<K>value - value whose presence in this map is to be testedpublic Object clone()
public Set<K> keySet()
MapKSSet 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.public Collection<Short> values()
MapKSCollection view of the values contained in this map. Note that this is a
inefficient operation since it triggers autoboxing of the short 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.public Set<MapKS.Entry<K>> entrySet()
MapKSSet 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.public void plus(MapKS<K> m)
MapKSpublic long dot(MapKS<K> m)
MapKSpublic void increment(K key)
MapKSCopyright © 2018. All rights reserved.