Package org.eclipse.mat.collect
Class HashMapObjectLong<E>
java.lang.Object
org.eclipse.mat.collect.HashMapObjectLong<E>
- All Implemented Interfaces:
Serializable
A map from Object to long.
More efficient than a general map
null not allowed as key.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
An entry from the map -
Constructor Summary
ConstructorDescriptionCreate a map of default sizeHashMapObjectLong
(int initialCapacity) Create a map of given size -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Remove all the existing mappings, leaving the capacity unchanged.boolean
containsKey
(E key) find if key is present in mapentries()
Iterate over all the map entrieslong
Retrieve the value corresponding to the keyObject[]
Get all the used keys.<T> T[]
getAllKeys
(T[] a) Get all the used keys.long[]
Get all the values corresponding to the used keys.boolean
isEmpty()
Is the map empty?keys()
Get a way of iterating over the keysboolean
Add a mappingboolean
Remove an mapping from the mapint
size()
The number of mappingsvalues()
Get a way of iterating over the values.
-
Constructor Details
-
HashMapObjectLong
public HashMapObjectLong()Create a map of default size -
HashMapObjectLong
public HashMapObjectLong(int initialCapacity) Create a map of given size- Parameters:
initialCapacity
- the initial capacity of the HashMap
-
-
Method Details
-
put
Add a mapping- Parameters:
key
- the keyvalue
- the corresponding value- Returns:
- true if an entry with the key already exists
-
remove
Remove an mapping from the map- Parameters:
key
- the key to remove- Returns:
- true if entry was found
-
containsKey
find if key is present in map- Parameters:
key
- the key- Returns:
- true if the key was found
-
get
Retrieve the value corresponding to the key- Parameters:
key
- the key- Returns:
- the value
- Throws:
NoSuchElementException
- if the key is not found
-
getAllKeys
Get all the used keys. Consider usinggetAllKeys(Object[])
for better type safety- Returns:
- an array of the used keys
-
getAllKeys
public <T> T[] getAllKeys(T[] a) Get all the used keys.- Type Parameters:
T
- the type of the keys- Parameters:
a
- an array of the right type for the output, which will be used if it is big enough, otherwise another array of this type will be allocated.- Returns:
- an array of the used keys
-
size
public int size()The number of mappings- Returns:
- the size of the map
-
isEmpty
public boolean isEmpty()Is the map empty?- Returns:
- true if no current mappings
-
clear
public void clear()Remove all the existing mappings, leaving the capacity unchanged. -
keys
Get a way of iterating over the keys- Returns:
- an iterator over the keys
-
values
Get a way of iterating over the values.- Returns:
- an iterator over the values
-
entries
Iterate over all the map entries- Returns:
- the iterator over the entries
-
getAllValues
public long[] getAllValues()Get all the values corresponding to the used keys. Duplicate values are possible if they correspond to different keys.- Returns:
- an array of the used values
-