|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttl.lin.data.map.HMapID
public class HMapID
Hash-based implementation of MapID.
| Field Summary |
|---|
| Fields inherited from interface tl.lin.data.map.MapID |
|---|
DEFAULT_VALUE |
| Constructor Summary | |
|---|---|
HMapID()
Constructs an empty HMapID with the default initial capacity (1024) and the default load factor (0.75). |
|
HMapID(int initialCapacity)
Constructs an empty HMapID with the specified initial capacity and the default load factor (0.75). |
|
HMapID(int initialCapacity,
float loadFactor)
Constructs an empty HMapID with the specified initial capacity and load factor. |
|
HMapID(MapID m)
Constructs a new HMapID with the same mappings as the specified MapID. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all of the mappings from this map. |
Object |
clone()
Returns a shallow copy of this HMapID 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(double value)
Returns true if this map contains one or more mappings with the specified value. |
double |
dot(MapID m)
Computes the dot product of this map with another map. |
Set<MapID.Entry> |
entrySet()
Returns a Set view of the mappings contained in this map. |
double |
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. |
MapID.Entry[] |
getEntriesSortedByValue()
Returns entries sorted by descending value. |
MapID.Entry[] |
getEntriesSortedByValue(int n)
Returns top n entries sorted by descending value. |
void |
increment(int key,
double 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. |
double |
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(MapID m)
Adds values of keys from another map to this map. |
double |
put(int key,
double value)
Associates the specified value with the specified key in this map. |
void |
putAll(MapID m)
Copies all of the mappings from the specified map to this map. |
double |
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<Double> |
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.MapID |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public HMapID(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacityloadFactor - the load factor
IllegalArgumentException - if the initial capacity is negative or the load factor is
nonpositivepublic HMapID(int initialCapacity)
initialCapacity - the initial capacity.
IllegalArgumentException - if the initial capacity is negative.public HMapID()
public HMapID(MapID 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()
MapID
size in interface MapIDpublic boolean isEmpty()
MapID
isEmpty in interface MapIDpublic double get(int key)
MapIDNoSuchElementException if this map contains no mapping for the key.
get in interface MapIDkey - the key whose associated value is to be returned
public boolean containsKey(int key)
MapID
containsKey in interface MapIDkey - key whose presence in this map is to be tested
public double put(int key,
double value)
MapID
put in interface MapIDkey - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic void putAll(MapID m)
MapID
putAll in interface MapIDm - mappings to be stored in this map
public void increment(int key,
double value)
key - key to incrementvalue - increment valuepublic double remove(int key)
MapID
remove in interface MapIDkey - key whose mapping is to be removed from the mappublic void clear()
MapID
clear in interface MapIDpublic boolean containsValue(double value)
MapID
containsValue in interface MapIDvalue - value whose presence in this map is to be tested
public Object clone()
clone in class Objectpublic Set<Integer> keySet()
MapIDSet 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.
keySet in interface MapIDpublic Collection<Double> values()
MapIDCollection view of the values contained in this map. Note that this is a
inefficient operation since it triggers autoboxing of the double 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 MapIDpublic Set<MapID.Entry> entrySet()
MapIDSet 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 MapIDpublic String toString()
toString in class Objectpublic void plus(MapID m)
m - the other mappublic double dot(MapID m)
m - the other mappublic double length()
public void normalize()
public MapID.Entry[] getEntriesSortedByValue()
public MapID.Entry[] getEntriesSortedByValue(int n)
n - number of entries to return
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||