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 Link icon

    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 Link icon

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

    Modifier and Type
    Method
    Description
    int
    indexOf(int value)
    Maps the value to index.
    static IntSet
    of(int k)
    Returns the IntSet of [0, k).
    static IntSet
    of(int[] samples)
    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 Link icon

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

    • values Link icon

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

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

      public final int min
      The minimum of values.
    • max Link icon

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

    • IntSet Link icon

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

    • size Link icon

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

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

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

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

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