Package smile.util

Class IntHashSet

java.lang.Object
smile.util.IntHashSet

public class IntHashSet extends Object
HashSet<int> for primitive types. Integer.MIN_VALUE (0x80000000) is not allowed as key.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty HashSet with the default initial capacity (16) and the default load factor (0.75).
    IntHashSet(int initialCapacity, float loadFactor)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(int key)
    Adds the specified element to this set if it is not already present.
    boolean
    contains(int key)
    Returns true if this set contains the specified element.
    boolean
    remove(int key)
    Removes the specified element from this set if it is present.
    int
    Returns the number of elements in this set.
    int[]
    Returns the elements as an array.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • IntHashSet

      public IntHashSet()
      Constructs an empty HashSet with the default initial capacity (16) and the default load factor (0.75).
    • IntHashSet

      public IntHashSet(int initialCapacity, float loadFactor)
      Constructor.
      Parameters:
      initialCapacity - the initial capacity.
      loadFactor - the load factor.
  • Method Details

    • contains

      public boolean contains(int key)
      Returns true if this set contains the specified element.
      Parameters:
      key - the element.
      Returns:
      true if this set contains the specified element.
    • add

      public boolean add(int key)
      Adds the specified element to this set if it is not already present. If this set already contains the element, the call leaves the set unchanged and returns false.
      Parameters:
      key - the element.
      Returns:
      true if this set didn't contain the specified element.
    • remove

      public boolean remove(int key)
      Removes the specified element from this set if it is present. Returns true if this set contained the element (or equivalently, if this set changed as a result of the call).
      Parameters:
      key - the element.
      Returns:
      true if this set contains the specified element.
    • size

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

      public int[] toArray()
      Returns the elements as an array.
      Returns:
      the elements as an array.