Class BmLongHashSet

  • All Implemented Interfaces:
    IBmLongSet

    public class BmLongHashSet
    extends Object
    implements IBmLongSet
    This code is adoption of 'HashMap' from Apache Harmony refactored to support primitive long keys.
    This implementation doesn't support removal of elements via itearator.
    • Constructor Detail

      • BmLongHashSet

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

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

        public BmLongHashSet​(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

      • add

        public void add​(long key)
        Description copied from interface: IBmLongSet
        Adds the specified element.
        Specified by:
        add in interface IBmLongSet
        Parameters:
        key - the element to add.
      • addAll

        public void addAll​(IBmLongSet values)
        Description copied from interface: IBmLongSet
        Adds all the values from the specified collection.
        Specified by:
        addAll in interface IBmLongSet
        Parameters:
        values - the collection of values to add.
      • addAll

        public void addAll​(Iterable<Long> values)
        Description copied from interface: IBmLongSet
        Adds all the values from the specified collection.
        Specified by:
        addAll in interface IBmLongSet
        Parameters:
        values - the collection of values to add.
      • addAll

        public void addAll​(long[] array)
        Description copied from interface: IBmLongSet
        Adds all the values from the specified array.
        Specified by:
        addAll in interface IBmLongSet
        Parameters:
        array - the array. May not be null.
      • contains

        public boolean contains​(long key)
        Description copied from interface: IBmLongSet
        Checks if the set contains the specified element.
        Specified by:
        contains in interface IBmLongSet
        Parameters:
        key - the element.
        Returns:
        true if set contains the specified element, false otherwise.
      • containsAny

        public boolean containsAny​(BmLongHashSet value)
        Checks if this set contains any element from the specified one.
        Parameters:
        set - the set to run the check against, may not be null.
        Returns:
        true if this map contains any element from the specified one, false otherwise.
      • iterator

        public IBmLongIterator iterator()
        Description copied from interface: IBmLongSet
        Gets the long value iterator
        Specified by:
        iterator in interface IBmLongSet
        Returns:
        The iterator of values. May not be null
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: IBmLongSet
        Checks whether this set is empty.
        Specified by:
        isEmpty in interface IBmLongSet
        Returns:
        true if this set has no elements, false otherwise.
        See Also:
        IBmLongSet.size()
      • keys

        public Collection<Long> keys()
        Description copied from interface: IBmLongSet
        Gets collection of elements.
        Specified by:
        keys in interface IBmLongSet
        Returns:
        the collection of elements.
      • remove

        public boolean remove​(long key)
        Description copied from interface: IBmLongSet
        Removes the specified element.
        Specified by:
        remove in interface IBmLongSet
        Parameters:
        key - the element to remove.
        Returns:
        true if this set contained the specified element, false otherwise.
      • removeAll

        public void removeAll​(IBmLongSet set)
        Removes from this set all of its elements that are contained in the specified set.
        Parameters:
        set - The set containing elements to be removed from this set, may not be null.
      • size

        public int size()
        Description copied from interface: IBmLongSet
        Returns the number of elements in this set.
        Specified by:
        size in interface IBmLongSet
        Returns:
        the number of elements in this set.
      • computeKeyHash

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