Class IntHashSet

java.lang.Object
org.yamcs.utils.IntHashSet
All Implemented Interfaces:
Iterable<Integer>

public class IntHashSet extends Object implements Iterable<Integer>
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty IntHashSet with the default capacity.
    Constructs a new IntHashSet and initializes it with values from the given IntArray.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(int value)
    Adds a value to the set if it is not already present.
    Creates and returns a copy of this IntHashSet.
    boolean
    contains(int value)
    Checks whether the set contains the given value.
    Returns an iterator over the elements in this set.
    boolean
    remove(int value)
    Removes the specified value from the set if it exists.
    int
    Returns the number of elements currently in the set.
     

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • IntHashSet

      public IntHashSet(IntArray a)
      Constructs a new IntHashSet and initializes it with values from the given IntArray.
      Parameters:
      a - the IntArray containing initial values for the set
    • IntHashSet

      public IntHashSet()
      Constructs an empty IntHashSet with the default capacity.
  • Method Details

    • add

      public boolean add(int value)
      Adds a value to the set if it is not already present.
      Parameters:
      value - the value to be added
      Returns:
      true if the value was added, false if it was already present
    • contains

      public boolean contains(int value)
      Checks whether the set contains the given value.
      Parameters:
      value - the value to check for presence in the set
      Returns:
      true if the value is present, false otherwise
    • remove

      public boolean remove(int value)
      Removes the specified value from the set if it exists.
      Parameters:
      value - the value to remove
      Returns:
      true if the set contained the value and it was removed, false otherwise
    • size

      public int size()
      Returns the number of elements currently in the set.
      Returns:
      the number of elements in the set
    • iterator

      public PrimitiveIterator.OfInt iterator()
      Returns an iterator over the elements in this set.
      Specified by:
      iterator in interface Iterable<Integer>
      Returns:
      an iterator for iterating over the set's values
    • clone

      public IntHashSet clone()
      Creates and returns a copy of this IntHashSet.
      Overrides:
      clone in class Object
      Returns:
      a new IntHashSet containing the same elements as this set
    • toString

      public String toString()
      Overrides:
      toString in class Object