com.hazelcast.client.impl.protocol.util
Class Int2ObjectHashMap<V>

java.lang.Object
  extended by com.hazelcast.client.impl.protocol.util.Int2ObjectHashMap<V>
Type Parameters:
V - values stored in the Map
All Implemented Interfaces:
Map<Integer,V>

public class Int2ObjectHashMap<V>
extends Object
implements Map<Integer,V>

Map implementation specialised for int keys using open addressing and linear probing for cache efficient access.


Nested Class Summary
 class Int2ObjectHashMap.EntryIterator<V>
           
 class Int2ObjectHashMap.KeyIterator
           
 class Int2ObjectHashMap.KeySet
           
static interface Int2ObjectHashMap.Supplier<T>
           
 class Int2ObjectHashMap.ValueIterator<T>
           
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
Int2ObjectHashMap()
           
Int2ObjectHashMap(int initialCapacity, double loadFactor)
          Construct a new map allowing a configuration for initial capacity and load factor.
 
Method Summary
 int capacity()
          Get the total capacity for the map to which the load factor with be a fraction of.
 void clear()
          
 void compact()
          Compact the Map backing arrays by rehashing with a capacity just larger than current size and giving consideration to the load factor.
 boolean containsKey(int key)
          Overloaded version of Map.containsKey(Object) that takes a primitive int key.
 boolean containsKey(Object key)
          
 boolean containsValue(Object value)
          
 Set<Map.Entry<Integer,V>> entrySet()
          
 V get(int key)
          Overloaded version of Map.get(Object) that takes a primitive int key.
 V get(Object key)
          
 V getOrDefault(int key, Int2ObjectHashMap.Supplier<V> supplier)
          Get a value for a given key, or if it does ot exist then default the value via a Int2ObjectHashMap.Supplier and put it in the map.
 boolean isEmpty()
          
 Int2ObjectHashMap.KeySet keySet()
          
 double loadFactor()
          Get the load factor beyond which the map will increase size.
 V put(Integer key, V value)
          
 V put(int key, V value)
          Overloaded version of Map.put(Object, Object) that takes a primitive int key.
 void putAll(Map<? extends Integer,? extends V> map)
          
 V remove(int key)
          Overloaded version of Map.remove(Object) that takes a primitive int key.
 V remove(Object key)
          
 int resizeThreshold()
          Get the actual threshold which when reached the map resize.
 int size()
          
 String toString()
          
 Collection<V> values()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

Int2ObjectHashMap

public Int2ObjectHashMap()

Int2ObjectHashMap

public Int2ObjectHashMap(int initialCapacity,
                         double loadFactor)
Construct a new map allowing a configuration for initial capacity and load factor.

Parameters:
initialCapacity - for the backing array
loadFactor - limit for resizing on puts
Method Detail

loadFactor

public double loadFactor()
Get the load factor beyond which the map will increase size.

Returns:
load factor for when the map should increase size.

capacity

public int capacity()
Get the total capacity for the map to which the load factor with be a fraction of.

Returns:
the total capacity for the map.

resizeThreshold

public int resizeThreshold()
Get the actual threshold which when reached the map resize. This is a function of the current capacity and load factor.

Returns:
the threshold when the map will resize.

size

public int size()

Specified by:
size in interface Map<Integer,V>

isEmpty

public boolean isEmpty()

Specified by:
isEmpty in interface Map<Integer,V>

containsKey

public boolean containsKey(Object key)

Specified by:
containsKey in interface Map<Integer,V>

containsKey

public boolean containsKey(int key)
Overloaded version of Map.containsKey(Object) that takes a primitive int key.

Parameters:
key - for indexing the Map
Returns:
true if the key is found otherwise false.

containsValue

public boolean containsValue(Object value)

Specified by:
containsValue in interface Map<Integer,V>

get

public V get(Object key)

Specified by:
get in interface Map<Integer,V>

get

public V get(int key)
Overloaded version of Map.get(Object) that takes a primitive int key.

Parameters:
key - for indexing the Map
Returns:
the value if found otherwise null

getOrDefault

public V getOrDefault(int key,
                      Int2ObjectHashMap.Supplier<V> supplier)
Get a value for a given key, or if it does ot exist then default the value via a Int2ObjectHashMap.Supplier and put it in the map.

Parameters:
key - to search on.
supplier - to provide a default if the get returns null.
Returns:
the value if found otherwise the default.

put

public V put(Integer key,
             V value)

Specified by:
put in interface Map<Integer,V>

put

public V put(int key,
             V value)
Overloaded version of Map.put(Object, Object) that takes a primitive int key.

Parameters:
key - for indexing the Map
value - to be inserted in the Map
Returns:
the previous value if found otherwise null

remove

public V remove(Object key)

Specified by:
remove in interface Map<Integer,V>

remove

public V remove(int key)
Overloaded version of Map.remove(Object) that takes a primitive int key.

Parameters:
key - for indexing the Map
Returns:
the value if found otherwise null

clear

public void clear()

Specified by:
clear in interface Map<Integer,V>

compact

public void compact()
Compact the Map backing arrays by rehashing with a capacity just larger than current size and giving consideration to the load factor.


putAll

public void putAll(Map<? extends Integer,? extends V> map)

Specified by:
putAll in interface Map<Integer,V>

keySet

public Int2ObjectHashMap.KeySet keySet()

Specified by:
keySet in interface Map<Integer,V>

values

public Collection<V> values()

Specified by:
values in interface Map<Integer,V>

entrySet

public Set<Map.Entry<Integer,V>> entrySet()

Specified by:
entrySet in interface Map<Integer,V>

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.