org.mapdb
Class LongHashMap<V>

java.lang.Object
  extended by org.mapdb.LongMap<V>
      extended by org.mapdb.LongHashMap<V>
All Implemented Interfaces:
Serializable

public class LongHashMap<V>
extends LongMap<V>
implements Serializable

LongHashMap is an implementation of LongMap without concurrency locking. This code is adoption of 'HashMap' from Apache Harmony refactored to support primitive long keys.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.mapdb.LongMap
LongMap.LongMapIterator<V>
 
Field Summary
protected  long hashSalt
          Salt added to keys before hashing, so it is harder to trigger hash collision attack.
 
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.
 V get(long key)
          Returns the value of the mapping with the specified key.
protected  long hashSaltValue()
           
static int intHash(int h)
           
 boolean isEmpty()
          Returns whether this map is empty.
static int longHash(long key)
           
 LongMap.LongMapIterator<V> longMapIterator()
           
 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.
 Iterator<V> valuesIterator()
           
 
Methods inherited from class org.mapdb.LongMap
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

hashSalt

protected final long hashSalt
Salt added to keys before hashing, so it is harder to trigger hash collision attack.

Constructor Detail

LongHashMap

public LongHashMap()
Constructs a new empty HashMap instance.


LongHashMap

public LongHashMap(int capacity)
Constructs a new HashMap instance with the specified capacity.

Parameters:
capacity - the initial capacity of this hash map.
Throws:
IllegalArgumentException - when the capacity is less than zero.

LongHashMap

public LongHashMap(int capacity,
                   float loadFactor)
Constructs a new HashMap instance with the specified capacity and load factor.

Parameters:
capacity - the initial capacity of this hash map.
loadFactor - the initial load factor.
Throws:
IllegalArgumentException - when the capacity is less than zero or the load factor is less or equal to zero.
Method Detail

hashSaltValue

protected long hashSaltValue()

clear

public void clear()
Removes all mappings from this hash map, leaving it empty.

Specified by:
clear in class LongMap<V>
See Also:
isEmpty(), size()

get

public V get(long key)
Returns the value of the mapping with the specified key.

Specified by:
get in class LongMap<V>
Parameters:
key - the key.
Returns:
the value of the mapping with the specified key, or null if no mapping for the specified key is found.

isEmpty

public boolean isEmpty()
Returns whether this map is empty.

Specified by:
isEmpty in class LongMap<V>
Returns:
true if this map has no elements, false otherwise.
See Also:
size()

put

public V put(long key,
             V value)
Maps the specified key to the specified value.

Specified by:
put in class LongMap<V>
Parameters:
key - the key.
value - the value.
Returns:
the value of any previous mapping with the specified key or null if there was no such mapping.

remove

public V remove(long key)
Removes the mapping with the specified key from this map.

Specified by:
remove in class LongMap<V>
Parameters:
key - the key of the mapping to remove.
Returns:
the value of the removed mapping or null if no mapping for the specified key was found.

size

public int size()
Returns the number of elements in this map.

Specified by:
size in class LongMap<V>
Returns:
the number of elements in this map.

valuesIterator

public Iterator<V> valuesIterator()
Specified by:
valuesIterator in class LongMap<V>
Returns:
iterator over values in map

longMapIterator

public LongMap.LongMapIterator<V> longMapIterator()
Specified by:
longMapIterator in class LongMap<V>

longHash

public static int longHash(long key)

intHash

public static int intHash(int h)


Copyright © 2014. All Rights Reserved.