|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.umd.cloud9.util.map.HMapIL
public class HMapIL
Hash-based implementation of the MapIL interface. MapIL is
a specialized variant the standard Java Map interface, except that
the keys are hard coded as ints and values are hard coded as longs for
efficiency reasons. 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 edu.umd.cloud9.util.map.MapIL |
|---|
DEFAULT_VALUE |
| Constructor Summary | |
|---|---|
HMapIL()
Constructs an empty HMapIL with the default initial capacity (1024) and the default load factor (0.75). |
|
HMapIL(int initialCapacity)
Constructs an empty HMapIL with the specified initial capacity and the default load factor (0.75). |
|
HMapIL(int initialCapacity,
float loadFactor)
Constructs an empty HMapIL with the specified initial capacity and load factor. |
|
HMapIL(MapIL m)
Constructs a new HMapIL with the same mappings as the specified MapIL. |
|
| Method Summary | |
|---|---|
void |
clear()
Removes all of the mappings from this map. |
Object |
clone()
Returns a shallow copy of this HMapIL 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(long value)
Returns true if this map contains one or more mappings with the specified value. |
int |
dot(MapIL m)
Computes the dot product of this map with another map. |
Set<MapIL.Entry> |
entrySet()
Returns a Set view of the mappings contained in this map. |
long |
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. |
MapIL.Entry[] |
getEntriesSortedByValue()
Returns entries sorted by descending value. |
MapIL.Entry[] |
getEntriesSortedByValue(int n)
Returns top n entries sorted by descending value. |
void |
increment(int key)
Increments the key. |
void |
increment(int key,
long 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. |
void |
plus(MapIL m)
Adds values of keys from another map to this map. |
long |
put(int key,
long value)
Associates the specified value with the specified key in this map. |
void |
putAll(MapIL m)
Copies all of the mappings from the specified map to this map. |
long |
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<Long> |
values()
Returns a Collection view of the values contained in this map. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface edu.umd.cloud9.util.map.MapIL |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public HMapIL(int initialCapacity,
float loadFactor)
initialCapacity - the initial capacityloadFactor - the load factor
IllegalArgumentException - if the initial capacity is negative or the load factor is
nonpositivepublic HMapIL(int initialCapacity)
initialCapacity - the initial capacity.
IllegalArgumentException - if the initial capacity is negative.public HMapIL()
public HMapIL(MapIL 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()
MapIL
size in interface MapILpublic boolean isEmpty()
MapIL
isEmpty in interface MapILpublic long get(int key)
MapILNoSuchElementException if this map contains no mapping for the key.
get in interface MapILkey - the key whose associated value is to be returned
public boolean containsKey(int key)
MapIL
containsKey in interface MapILkey - key whose presence in this map is to be tested
public long put(int key,
long value)
MapIL
put in interface MapILkey - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic void putAll(MapIL m)
MapIL
putAll in interface MapILm - mappings to be stored in this mappublic long remove(int key)
MapIL
remove in interface MapILkey - key whose mapping is to be removed from the mappublic void clear()
MapIL
clear in interface MapILpublic boolean containsValue(long value)
MapIL
containsValue in interface MapILvalue - value whose presence in this map is to be tested
public Object clone()
clone in class Objectpublic Set<Integer> keySet()
MapILSet 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 MapILpublic Collection<Long> values()
MapILCollection view of the values contained in this map.
Note that this is a inefficient operation since it triggers autoboxing of
the int 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 MapILpublic Set<MapIL.Entry> entrySet()
MapILSet 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. See Map.entrySet() for more details.
entrySet in interface MapILpublic String toString()
toString in class Objectpublic void plus(MapIL m)
m - the other mappublic int dot(MapIL m)
m - the other mappublic void increment(int key)
key - key to increment
public void increment(int key,
long value)
public MapIL.Entry[] getEntriesSortedByValue()
public MapIL.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 | |||||||||