Package smile.util
Class IntSet
java.lang.Object
smile.util.IntSet
- All Implemented Interfaces:
Serializable
A set of integers.
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
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
size()
Returns the number of values.int
valueOf
(int index) Maps an index to the corresponding value.
-
Field Details
-
values
public final int[] valuesMap of index to original values. -
index
Map of values to index. -
min
public final int minThe minimum of values. -
max
public final int maxThe 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 value) Maps the value to index.- Parameters:
value
- the value.- Returns:
- the index.
-
of
Returns the IntSet of [0, k).- Parameters:
k
- the number of unique values.- Returns:
- the set.
-
of
Finds the unique values from samples.- Parameters:
samples
- the samples.- Returns:
- the set.
-