|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjdbm.helper.LongHashMap<V>
public class LongHashMap<V>
Hash Map which uses primitive long as key. Main advantage is new instanceof of Long does not have to be created for each lookup.
This code comes from Android, which in turns comes to Apache Harmony. This class was modified to use primitive longs and stripped down to consume less space.
Author of JDBM modifications: Jan Kotek
Note: This map have weakened hash function, this works well for JDBM, but may be wrong for many other applications.
Constructor Summary | |
---|---|
LongHashMap()
Constructs a new empty HashMap instance. |
|
LongHashMap(int capacity)
Constructs a new HashMap instance with the specified capacity. |
|
LongHashMap(int capacity,
float loadFactor)
Constructs a new HashMap instance with the specified capacity and
load factor. |
Method Summary | |
---|---|
void |
clear()
Removes all mappings from this hash map, leaving it empty. |
boolean |
containsKey(long key)
Returns whether this map contains the specified key. |
boolean |
containsValue(java.lang.Object value)
Returns whether this map contains the specified value. |
V |
get(long key)
Returns the value of the mapping with the specified key. |
boolean |
isEmpty()
Returns whether this map is empty. |
V |
put(long key,
V value)
Maps the specified key to the specified value. |
V |
remove(long key)
Removes the mapping with the specified key from this map. |
int |
size()
Returns the number of elements in this map. |
java.util.Iterator<V> |
valuesIterator()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LongHashMap()
HashMap
instance.
public LongHashMap(int capacity)
HashMap
instance with the specified capacity.
capacity
- the initial capacity of this hash map.
java.lang.IllegalArgumentException
- when the capacity is less than zero.public LongHashMap(int capacity, float loadFactor)
HashMap
instance with the specified capacity and
load factor.
capacity
- the initial capacity of this hash map.loadFactor
- the initial load factor.
java.lang.IllegalArgumentException
- when the capacity is less than zero or the load factor is
less or equal to zero.Method Detail |
---|
public void clear()
isEmpty()
,
size()
public boolean containsKey(long key)
key
- the key to search for.
true
if this map contains the specified key,
false
otherwise.public boolean containsValue(java.lang.Object value)
value
- the value to search for.
true
if this map contains the specified value,
false
otherwise.public V get(long key)
key
- the key.
null
if no mapping for the specified key is found.public boolean isEmpty()
true
if this map has no elements, false
otherwise.size()
public V put(long key, V value)
key
- the key.value
- the value.
null
if there was no such mapping.public V remove(long key)
key
- the key of the mapping to remove.
null
if no mapping
for the specified key was found.public int size()
public java.util.Iterator<V> valuesIterator()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |