Package smile.util

Interface Index

All Superinterfaces:
Serializable

public interface Index extends Serializable
Immutable sequence used for indexing.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    apply(int i)
    Returns the index to underlying data.
    default Index
    flatten(Index 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
    range(Integer start, Integer end, Integer step)
    Returns the range index for [start, end) with the given incremental step.
    int
    Returns the number of elements in the index.
    Returns an integer stream of elements in the index.
    default int[]
    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

      default Index flatten(Index index)
      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

      static Index of(int... indices)
      Returns the index of multiple elements in a dimension.
      Parameters:
      indices - the indices of multiple elements.
      Returns:
      the index.
    • of

      static Index of(boolean... mask)
      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

      static Index range(int start, int end)
      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

      static Index range(Integer start, Integer end, Integer step)
      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.