Class LongHashSet


  • public class LongHashSet
    extends java.lang.Object
    This is a bare-bones, application specific, optimized hash set implementation. We feel this will perform better than the java.util.HashMap implementation for our application both in terms of execution time and memory usage. This is an UNSYNCHRONIZED IMPLEMENTATION!
    Since:
    11gR2
    • Constructor Summary

      Constructors 
      Constructor Description
      LongHashSet()
      Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
      LongHashSet​(int initialCapacity)
      Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor, which is 0.75.
      LongHashSet​(int initialCapacity, float loadFactor)
      Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and the specified load factor.
      LongHashSet​(java.util.Collection<java.lang.Long> c)
      Constructs a new set containing the elements in the specified collection.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(long o)
      Adds the specified element to this set if it is not already present.
      void clear()
      Removes all of the elements from this set.
      java.lang.Object clone()
      Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.
      boolean contains​(long o)
      Returns true if this set contains the specified element.
      boolean isEmpty()
      Returns true if this set contains no elements.
      boolean remove​(long o)
      Removes the specified element from this set if it is present.
      int size()
      Returns the number of elements in this set (its cardinality).
      long[] toArray()
      Returns an array of the elements in this set.
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LongHashSet

        public LongHashSet()
        Constructs a new, empty set; the backing HashMap instance has default initial capacity (16) and load factor (0.75).
      • LongHashSet

        public LongHashSet​(java.util.Collection<java.lang.Long> c)
        Constructs a new set containing the elements in the specified collection. The HashMap is created with default load factor (0.75) and an initial capacity sufficient to contain the elements in the specified collection.
        Parameters:
        c - the collection whose elements are to be placed into this set.
        Throws:
        java.lang.NullPointerException - if the specified collection is null.
      • LongHashSet

        public LongHashSet​(int initialCapacity,
                           float loadFactor)
        Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and the specified load factor.
        Parameters:
        initialCapacity - the initial capacity of the hash map.
        loadFactor - the load factor of the hash map.
        Throws:
        java.lang.IllegalArgumentException - if the initial capacity is less than zero, or if the load factor is nonpositive.
      • LongHashSet

        public LongHashSet​(int initialCapacity)
        Constructs a new, empty set; the backing HashMap instance has the specified initial capacity and default load factor, which is 0.75.
        Parameters:
        initialCapacity - the initial capacity of the hash table.
        Throws:
        java.lang.IllegalArgumentException - if the initial capacity is less than zero.
    • Method Detail

      • toArray

        public long[] toArray()
        Returns an array of the elements in this set. The elements are returned in no particular order.
        Returns:
        an array of the elements in this set.
        See Also:
        ConcurrentModificationException
      • size

        public int size()
        Returns the number of elements in this set (its cardinality).
        Returns:
        the number of elements in this set (its cardinality).
      • isEmpty

        public boolean isEmpty()
        Returns true if this set contains no elements.
        Returns:
        true if this set contains no elements.
      • contains

        public boolean contains​(long o)
        Returns true if this set contains the specified element.
        Parameters:
        o - element whose presence in this set is to be tested.
        Returns:
        true if this set contains the specified element.
      • add

        public boolean add​(long o)
        Adds the specified element to this set if it is not already present.
        Parameters:
        o - element to be added to this set.
        Returns:
        true if the set did not already contain the specified element.
      • remove

        public boolean remove​(long o)
        Removes the specified element from this set if it is present.
        Parameters:
        o - object to be removed from this set, if present.
        Returns:
        true if the set contained the specified element.
      • clear

        public void clear()
        Removes all of the elements from this set.
      • clone

        public java.lang.Object clone()
        Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a shallow copy of this set.