Class BmLongHashMap<V>

java.lang.Object
com._1c.g5.v8.bm.common.collections.BmLongHashMap<V>
All Implemented Interfaces:
IBmLongMap<V>

public class BmLongHashMap<V> extends Object implements IBmLongMap<V>
This code is adoption of 'HashMap' from Apache Harmony refactored to support primitive long keys.
This implementation doesn't support removal of entries via itearator.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     

    Nested classes/interfaces inherited from interface com._1c.g5.v8.bm.common.collections.IBmLongMap

    IBmLongMap.IEntry<V>
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new empty HashMap instance.
    BmLongHashMap(int capacity)
    Constructs a new HashMap instance with the specified capacity.
    BmLongHashMap(int capacity, float loadFactor)
    Constructs a new HashMap instance with the specified capacity and load factor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all mappings from this hash map, leaving it empty.
    protected int
    computeKeyHash(long key)
    Computes key hash.
    boolean
    containsKey(long key)
    Checks if the map contains the specified key.
    Returns a Iterable view of the entries in this map.
    get(long key)
    Returns the value of the mapping with the specified key.
    boolean
    Returns whether this map is empty.
    Gets keys contained in this map.
    put(long key, V value)
    Maps the specified key to the specified value.
    void
    Copies all of the mappings from the specified map to this map.
    void
    putAll(Map<Long,V> values)
    Copies all of the mappings from the specified map to this map.
    remove(long key)
    Removes the mapping with the specified key from this map.
    int
    Returns the number of elements in this map.
    Gets values contained in this map.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com._1c.g5.v8.bm.common.collections.IBmLongMap

    putAll
  • Constructor Details

    • BmLongHashMap

      public BmLongHashMap()
      Constructs a new empty HashMap instance.
    • BmLongHashMap

      public BmLongHashMap(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.
    • BmLongHashMap

      public BmLongHashMap(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 Details

    • clear

      public void clear()
      Description copied from interface: IBmLongMap
      Removes all mappings from this hash map, leaving it empty.
      Specified by:
      clear in interface IBmLongMap<V>
      See Also:
    • get

      public V get(long key)
      Description copied from interface: IBmLongMap
      Returns the value of the mapping with the specified key.
      Specified by:
      get in interface IBmLongMap<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()
      Description copied from interface: IBmLongMap
      Returns whether this map is empty.
      Specified by:
      isEmpty in interface IBmLongMap<V>
      Returns:
      true if this map has no elements, false otherwise.
      See Also:
    • put

      public V put(long key, V value)
      Description copied from interface: IBmLongMap
      Maps the specified key to the specified value.
      Specified by:
      put in interface IBmLongMap<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)
      Description copied from interface: IBmLongMap
      Removes the mapping with the specified key from this map.
      Specified by:
      remove in interface IBmLongMap<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()
      Description copied from interface: IBmLongMap
      Returns the number of elements in this map.
      Specified by:
      size in interface IBmLongMap<V>
      Returns:
      the number of elements in this map.
    • entryIterable

      public Iterable<IBmLongMap.IEntry<V>> entryIterable()
      Description copied from interface: IBmLongMap
      Returns a Iterable view of the entries in this map.
      Specified by:
      entryIterable in interface IBmLongMap<V>
      Returns:
    • putAll

      public void putAll(BmLongHashMap<V> values)
      Copies all of the mappings from the specified map to this map.
      Parameters:
      map - the map to copy mappings from, may not be null.
    • putAll

      public void putAll(Map<Long,V> values)
      Copies all of the mappings from the specified map to this map.
      Specified by:
      putAll in interface IBmLongMap<V>
      Parameters:
      map - the map to copy mappings from, may not be null.
    • containsKey

      public boolean containsKey(long key)
      Description copied from interface: IBmLongMap
      Checks if the map contains the specified key.
      Specified by:
      containsKey in interface IBmLongMap<V>
      Parameters:
      key - the key to check.
      Returns:
      true if the map contains the specified key, false otherwise.
    • values

      public List<V> values()
      Description copied from interface: IBmLongMap
      Gets values contained in this map.
      Specified by:
      values in interface IBmLongMap<V>
      Returns:
      a collection of values, never null.
    • keys

      public Collection<Long> keys()
      Description copied from interface: IBmLongMap
      Gets keys contained in this map.
      Specified by:
      keys in interface IBmLongMap<V>
      Returns:
      a collection of keys, never null.
    • computeKeyHash

      protected int computeKeyHash(long key)
      Computes key hash.
      Parameters:
      key - The key to compute hash for.
      Returns:
      the key hash.