com.hazelcast.util.collection

## Class Object2LongHashMap<K>

- java.lang.Object
- - com.hazelcast.util.collection.Object2LongHashMap<K>

- Type Parameters:
    `K` - type of keys stored in the `Map`
  All Implemented Interfaces:
    Map<K,Long>

      public class Object2LongHashMap<K>
      extends Object
      implements Map<K,Long>

  `Map` implementation specialised for long values using open addressing and linear probing for cache efficient access. The implementation is mirror copy of `Long2ObjectHashMap` and it also relies on missing value concept from `Long2LongHashMap`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `Object2LongHashMap.EntryIterator`
    `class` | `Object2LongHashMap.EntrySet`
    `class` | `Object2LongHashMap.KeyIterator`
    `class` | `Object2LongHashMap.KeySet`
    `class` | `Object2LongHashMap.ValueCollection`
    `class` | `Object2LongHashMap.ValueIterator`

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Object2LongHashMap(int initialCapacity, float loadFactor, long missingValue)` Construct a new map allowing a configuration for initial capacity and load factor.
    `Object2LongHashMap(int initialCapacity, float loadFactor, long missingValue, boolean shouldAvoidAllocation)` Construct a new map allowing a configuration for initial capacity and load factor.
    `Object2LongHashMap(long missingValue)` Construct a map with default capacity and load factor.
    `Object2LongHashMap(Object2LongHashMap<K> mapToCopy)` Copy construct a new map from an existing one.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `capacity()` Get the total capacity for the map to which the load factor will 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(Object key)` Overloaded version of `Map.containsKey(Object)` that takes a primitive long key.
    `boolean` | `containsValue(long value)`
    `boolean` | `containsValue(Object value)`
    `Object2LongHashMap.EntrySet` | `entrySet()`
    `boolean` | `equals(Object o)`
    `Long` | `get(Object key)`
    `long` | `getValue(K key)` Overloaded version of `Map.get(Object)` that takes a primitive long key.
    `int` | `hashCode()`
    `boolean` | `isEmpty()`
    `Object2LongHashMap.KeySet` | `keySet()`
    `float` | `loadFactor()` Get the load factor beyond which the map will increase size.
    `long` | `missingValue()` The value to be used as a null marker in the map.
    `long` | `put(K key, long value)` Overloaded version of `Map.put(Object, Object)` that takes a primitive long key.
    `Long` | `put(K key, Long value)`
    `void` | `putAll(Map<? extends K,? extends Long> map)`
    `Long` | `remove(Object key)`
    `long` | `removeKey(K key)` Overloaded version of `Map.remove(Object)` that takes a primitive long key.
    `long` | `replace(K key, long value)` Primitive specialised version of `Map.replace(Object, Object)`
    `boolean` | `replace(K key, long oldValue, long newValue)` Primitive specialised version of `Map.replace(Object, Object, Object)`
    `int` | `resizeThreshold()` Get the actual threshold which when reached the map will resize.
    `int` | `size()`
    `String` | `toString()`
    `Object2LongHashMap.ValueCollection` | `values()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Map

      `compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll`

- - ### Constructor Detail

    - #### Object2LongHashMap

          public Object2LongHashMap(long missingValue)

      Construct a map with default capacity and load factor.
      Parameters:
        `missingValue` - value to be used as a null maker in the map

    - #### Object2LongHashMap

          public Object2LongHashMap(int initialCapacity,
                                    float loadFactor,
                                    long missingValue)

      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
        `missingValue` - value to be used as a null marker in the map

    - #### Object2LongHashMap

          public Object2LongHashMap(int initialCapacity,
                                    float loadFactor,
                                    long missingValue,
                                    boolean shouldAvoidAllocation)

      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
        `missingValue` - value to be used as a null marker in the map
        `shouldAvoidAllocation` - should allocation be avoided by caching iterators and map entries.

    - #### Object2LongHashMap

          public Object2LongHashMap(Object2LongHashMap<K> mapToCopy)

      Copy construct a new map from an existing one.
      Parameters:
        `mapToCopy` - for construction.

  - ### Method Detail

    - #### missingValue

          public long missingValue()

      The value to be used as a null marker in the map.
      Returns:
        value to be used as a null marker in the map.

    - #### loadFactor

          public float 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 will be a fraction of.
      Returns:
        the total capacity for the map.

    - #### resizeThreshold

          public int resizeThreshold()

      Get the actual threshold which when reached the map will 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<K,Long>`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `Map<K,Long>`

    - #### containsKey

          public boolean containsKey(Object key)

      Overloaded version of `Map.containsKey(Object)` that takes a primitive long key.
      Specified by:
        `containsKey` in interface `Map<K,Long>`
      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<K,Long>`

    - #### containsValue

          public boolean containsValue(long value)

    - #### get

          public Long get(Object key)

      Specified by:
        `get` in interface `Map<K,Long>`

    - #### getValue

          public long getValue(K key)

      Overloaded version of `Map.get(Object)` that takes a primitive long key. Due to type erasure have to rename the method
      Parameters:
        `key` - for indexing the `Map`
      Returns:
        the value if found otherwise missingValue

    - #### put

          public Long put(K key,
                          Long value)

      Specified by:
        `put` in interface `Map<K,Long>`

    - #### put

          public long put(K key,
                          long value)

      Overloaded version of `Map.put(Object, Object)` that takes a primitive long key.
      Parameters:
        `key` - for indexing the `Map`
        `value` - to be inserted in the `Map`
      Returns:
        the previous value if found otherwise missingValue

    - #### remove

          public Long remove(Object key)

      Specified by:
        `remove` in interface `Map<K,Long>`

    - #### removeKey

          public long removeKey(K key)

      Overloaded version of `Map.remove(Object)` that takes a primitive long key. Due to type erasure have to rename the method
      Parameters:
        `key` - for indexing the `Map`
      Returns:
        the value if found otherwise missingValue

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `Map<K,Long>`

    - #### 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 K,? extends Long> map)

      Specified by:
        `putAll` in interface `Map<K,Long>`

    - #### keySet

          public Object2LongHashMap.KeySet keySet()

      Specified by:
        `keySet` in interface `Map<K,Long>`

    - #### values

          public Object2LongHashMap.ValueCollection values()

      Specified by:
        `values` in interface `Map<K,Long>`

    - #### entrySet

          public Object2LongHashMap.EntrySet entrySet()

      Specified by:
        `entrySet` in interface `Map<K,Long>`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Specified by:
        `equals` in interface `Map<K,Long>`
      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in interface `Map<K,Long>`
      Overrides:
        `hashCode` in class `Object`

    - #### replace

          public long replace(K key,
                              long value)

      Primitive specialised version of `Map.replace(Object, Object)`
      Parameters:
        `key` - key with which the specified value is associated
        `value` - value to be associated with the specified key
      Returns:
        the previous value associated with the specified key, or `null` if there was no mapping for the key.

    - #### replace

          public boolean replace(K key,
                                 long oldValue,
                                 long newValue)

      Primitive specialised version of `Map.replace(Object, Object, Object)`
      Parameters:
        `key` - key with which the specified value is associated
        `oldValue` - value expected to be associated with the specified key
        `newValue` - value to be associated with the specified key
      Returns:
        `true` if the value was replaced

Copyright © 2020. All rights reserved.