Package smile.util
Interface Index
- All Superinterfaces:
Serializable
Immutable sequence used for indexing.
-
Method Summary
Modifier and TypeMethodDescriptionint
apply
(int i) Returns the index to underlying data.default Index
Flatten the index of index.static Index
of
(boolean... mask) Returns the index of multiple elements in a dimension.static Index
of
(int... indices) Returns the index of multiple elements in a dimension.static Index
range
(int start, int end) Returns the range index for [start, end) with incremental step 1.static Index
Returns the range index for [start, end) with the given incremental step.int
size()
Returns the number of elements in the index.stream()
Returns an integer stream of elements in the index.default int[]
toArray()
Returns an integer array of elements in the index.
-
Method Details
-
size
int size()Returns the number of elements in the index.- Returns:
- the number of elements in the index.
-
apply
int apply(int i) Returns the index to underlying data.- Parameters:
i
- the index to data element.- Returns:
- the index to underlying data.
-
stream
IntStream stream()Returns an integer stream of elements in the index.- Returns:
- an integer stream of elements in the index.
-
toArray
default int[] toArray()Returns an integer array of elements in the index.- Returns:
- an integer array of elements in the index.
-
flatten
Flatten the index of index. Returns the index to the underlying data.- Parameters:
index
- the index to the elements in this index.- Returns:
- the index to the underlying data.
-
of
Returns the index of multiple elements in a dimension.- Parameters:
indices
- the indices of multiple elements.- Returns:
- the index.
-
of
Returns the index of multiple elements in a dimension.- Parameters:
mask
- the boolean flags to select multiple elements. The length of array should match that of the corresponding dimension of tensor.- Returns:
- the index.
-
range
Returns the range index for [start, end) with incremental step 1.- Parameters:
start
- the inclusive start index.end
- the exclusive end index.- Returns:
- the range index.
-
range
Returns the range index for [start, end) with the given incremental step.- Parameters:
start
- the inclusive start index.end
- the exclusive end index.step
- the incremental step.- Returns:
- the range index.
-