Package org.eclipse.mat.collect
Class HashMapLongObject<E>
- java.lang.Object
-
- org.eclipse.mat.collect.HashMapLongObject<E>
-
- All Implemented Interfaces:
java.io.Serializable
public final class HashMapLongObject<E> extends java.lang.Object implements java.io.SerializableA map from long to Object. More efficient than a general map- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceHashMapLongObject.Entry<E>An entry from the map
-
Constructor Summary
Constructors Constructor Description HashMapLongObject()Create a map of default sizeHashMapLongObject(int initialCapacity)Create a map of given capacity
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Remove all the existing mappings, leaving the capacity unchanged.booleancontainsKey(long key)find if key is present in mapjava.util.Iterator<HashMapLongObject.Entry<E>>entries()Iterate over all the map entriesEget(long key)Retrieve the value corresponding to the keylong[]getAllKeys()Get all the used keysjava.lang.Object[]getAllValues()Get all the values corresponding to the used keys.<T> T[]getAllValues(T[] a)Get all the values corresponding to the used keys.booleanisEmpty()Is the map emptyIteratorLongkeys()Get a way of iterating over the keysEput(long key, E value)Add a mappingEremove(long key)Remove an mapping from the mapintsize()The number of mappingsjava.util.Iterator<E>values()Get a way of iterating over the values.
-
-
-
Method Detail
-
put
public E put(long key, E value)
Add a mapping- Parameters:
key- the keyvalue- the corresponding value- Returns:
- the old value if an entry with the key already exists
-
remove
public E remove(long key)
Remove an mapping from the map- Parameters:
key- the key to remove- Returns:
- the old value if the key was found, otherwise null
-
containsKey
public boolean containsKey(long key)
find if key is present in map- Parameters:
key- the key- Returns:
- true if the key was found
-
get
public E get(long key)
Retrieve the value corresponding to the key- Parameters:
key- the key- Returns:
- the value, or null if the key is not found
-
getAllKeys
public long[] getAllKeys()
Get all the used keys- Returns:
- an array of the used keys
-
getAllValues
public java.lang.Object[] getAllValues()
Get all the values corresponding to the used keys. Duplicate values are possible if they correspond to different keys. Consider usinggetAllValues(Object[])for better type safety.- Returns:
- an array of the used values
-
getAllValues
public <T> T[] getAllValues(T[] a)
Get all the values corresponding to the used keys. Duplicate values are possible if they correspond to different keys.- Type Parameters:
T- The type of values held in this map.- 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 values
-
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
public IteratorLong keys()
Get a way of iterating over the keys- Returns:
- an iterator over the keys
-
values
public java.util.Iterator<E> values()
Get a way of iterating over the values.- Returns:
- an iterator over the values
-
entries
public java.util.Iterator<HashMapLongObject.Entry<E>> entries()
Iterate over all the map entries- Returns:
- the iterator over the entries
-
-