Package smile.util

Class IntSet

java.lang.Object
smile.util.IntSet
All Implemented Interfaces:
Serializable

public class IntSet extends Object implements Serializable
A set of integers.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Map<Integer,Integer>
    Map of values to index.
    final int
    The maximum of values.
    final int
    The minimum of values.
    final int[]
    Map of index to original values.
  • Constructor Summary

    Constructors
    Constructor
    Description
    IntSet(int[] values)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    indexOf(int x)
    Maps the value to index.
    static IntSet
    of(int k)
    Returns the IntSet of [0, k).
    static IntSet
    of(int[] y)
    Finds the unique values from samples.
    int
    Returns the number of values.
    int
    valueOf(int index)
    Maps an index to the corresponding value.

    Methods inherited from class java.lang.Object

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

    • values

      public final int[] values
      Map of index to original values.
    • index

      protected final Map<Integer,Integer> index
      Map of values to index.
    • min

      public final int min
      The minimum of values.
    • max

      public final int max
      The maximum of values.
  • Constructor Details

    • IntSet

      public IntSet(int[] values)
      Constructor.
      Parameters:
      values - the unique values.
  • Method Details

    • size

      public int size()
      Returns the number of values.
      Returns:
      the number of values.
    • valueOf

      public int valueOf(int index)
      Maps an index to the corresponding value.
      Parameters:
      index - the index.
      Returns:
      the value.
    • indexOf

      public int indexOf(int x)
      Maps the value to index.
      Parameters:
      x - the value.
      Returns:
      the index.
    • of

      public static IntSet of(int k)
      Returns the IntSet of [0, k).
      Parameters:
      k - the number of unique values.
      Returns:
      the set.
    • of

      public static IntSet of(int[] y)
      Finds the unique values from samples.
      Parameters:
      y - the samples.
      Returns:
      the set.