public class HMapIF extends Object implements MapIF, Cloneable, Serializable
MapIF.DEFAULT_VALUE| Constructor and Description |
|---|
HMapIF()
Constructs an empty HMapIF with the default initial capacity (1024) and the default
load factor (0.75).
|
HMapIF(int initialCapacity)
Constructs an empty HMapIF with the specified initial capacity and the default load
factor (0.75).
|
HMapIF(int initialCapacity,
float loadFactor)
Constructs an empty HMapIF with the specified initial capacity and load factor.
|
HMapIF(MapIF m)
Constructs a new HMapIF with the same mappings as the specified MapIF.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all of the mappings from this map.
|
Object |
clone()
Returns a shallow copy of this HMapIF instance: the keys and values themselves are not
cloned.
|
boolean |
containsKey(int key)
Returns true if this map contains a mapping for the specified key.
|
boolean |
containsValue(float value)
Returns true if this map contains one or more mappings with the specified value.
|
double |
dot(MapIF m)
Computes the dot product of this map with another map.
|
Set<MapIF.Entry> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
float |
get(int key)
Returns the value to which the specified key is mapped, or throws
NoSuchElementException if this map contains no mapping for the key. |
MapIF.Entry[] |
getEntriesSortedByValue()
Returns entries sorted by descending value.
|
MapIF.Entry[] |
getEntriesSortedByValue(int n)
Returns top n entries sorted by descending value.
|
void |
increment(int key)
Increments the key.
|
void |
increment(int key,
float value)
Increments the key by some value.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
Set<Integer> |
keySet()
Returns a
Set view of the keys contained in this map. |
float |
length()
Returns the length of the vector represented by this map.
|
void |
normalize()
Normalizes values such that the vector represented by this map has unit length.
|
void |
plus(MapIF m)
Adds values of keys from another map to this map.
|
float |
put(int key,
float value)
Associates the specified value with the specified key in this map.
|
void |
putAll(MapIF m)
Copies all of the mappings from the specified map to this map.
|
float |
remove(int 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<Float> |
values()
Returns a
Collection view of the values contained in this map. |
public HMapIF(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacityloadFactor - the load factorIllegalArgumentException - if the initial capacity is negative or the load factor is
nonpositivepublic HMapIF(int initialCapacity)
initialCapacity - the initial capacity.IllegalArgumentException - if the initial capacity is negative.public HMapIF()
public HMapIF(MapIF m)
m - the map whose mappings are to be placed in this mapNullPointerException - if the specified map is nullpublic int size()
MapIFpublic boolean isEmpty()
MapIFpublic float get(int key)
MapIFNoSuchElementException if this map contains no mapping for the key.public boolean containsKey(int key)
MapIFcontainsKey in interface MapIFkey - key whose presence in this map is to be testedpublic float put(int key,
float value)
MapIFpublic void putAll(MapIF m)
MapIFpublic float remove(int key)
MapIFpublic void clear()
MapIFpublic boolean containsValue(float value)
MapIFcontainsValue in interface MapIFvalue - value whose presence in this map is to be testedpublic Object clone()
public Set<Integer> keySet()
MapIFSet view of the keys contained in this map. Note that this is a inefficient
operation since it triggers autoboxing of the int keys, 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 Collection<Float> values()
MapIFCollection view of the values contained in this map. Note that this is a
inefficient operation since it triggers autoboxing of the float 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<MapIF.Entry> entrySet()
MapIFSet 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(MapIF m)
MapIFpublic double dot(MapIF m)
MapIFpublic void increment(int key)
MapIFpublic void increment(int key,
float value)
MapIFpublic float length()
public void normalize()
public MapIF.Entry[] getEntriesSortedByValue()
public MapIF.Entry[] getEntriesSortedByValue(int n)
n - number of entries to returnCopyright © 2014. All rights reserved.