org.eclipse.january.dataset

## Class SliceND

- java.lang.Object
- - org.eclipse.january.dataset.SliceND

-     public class SliceND
      extends Object

  Class to represent a slice through all dimensions of a multi-dimensional dataset. A slice comprises a starting position array, a stopping position array (not included) and a stepping size array. If a maximum shape is specified, slicing past the original shape is supported for positive steps otherwise it is ignored. With unlimited dimensions, extending past the original shape is only allowed if the stopping value is given.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SliceND(int[] shape)` Construct ND slice for whole of shape
    `SliceND(int[] shape, int[] start, int[] stop, int[] step)` Construct ND slice parameters
    `SliceND(int[] shape, int[] maxShape, int[] start, int[] stop, int[] step)` Construct ND slice parameters
    `SliceND(int[] shape, int[] maxShape, Slice... slice)` Construct ND slice from an array of 1D slices
    `SliceND(int[] shape, Slice... slice)` Construct ND slice from an array of 1D slices

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `SliceND` | `clone()`
    `Slice[]` | `convertToSlice()` Convert to a slice array
    `static SliceND` | `createSlice(ILazyDataset data, int[] start, int[] stop)` Creating slice from dataset
    `static SliceND` | `createSlice(ILazyDataset data, int[] start, int[] stop, int[] step)` Creating slice from dataset
    `SliceND` | `flip()` Flip slice direction in all dimensions so slice begins at previous end point, steps in the opposite direction, and finishes at the previous start point
    `SliceND` | `flip(int i)` Flip slice direction in given dimension so slice begins at previous end point, steps in the opposite direction, and finishes at the previous start point
    `int[]` | `getMaxShape()`
    `int[]` | `getShape()`
    `int[]` | `getSourceShape()`
    `int[]` | `getStart()`
    `int[]` | `getStep()`
    `int[]` | `getStop()` Note stop values are clamped to -1 for negative steps
    `boolean` | `isAll()`
    `boolean` | `isExpanded()`
    `void` | `setSlice(int i, Integer start, Integer stop, int step)` Set slice for given dimension
    `void` | `setSlice(int i, int start, int stop, int step)` Set slice for given dimension
    `void` | `setSlice(int i, Slice slice)` Set slice for given dimension
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SliceND

          public SliceND(int[] shape)

      Construct ND slice for whole of shape
      Parameters:
        `shape` -

    - #### SliceND

          public SliceND(int[] shape,
                 Slice... slice)

      Construct ND slice from an array of 1D slices
      Parameters:
        `shape` -
        `slice` -

    - #### SliceND

          public SliceND(int[] shape,
                 int[] maxShape,
                 Slice... slice)

      Construct ND slice from an array of 1D slices
      Parameters:
        `shape` -
        `maxShape` - can be null
        `slice` -

    - #### SliceND

          public SliceND(int[] shape,
                 int[] start,
                 int[] stop,
                 int[] step)

      Construct ND slice parameters
      Parameters:
        `shape` -
        `start` - can be null
        `stop` - can be null
        `step` - can be null

    - #### SliceND

          public SliceND(int[] shape,
                 int[] maxShape,
                 int[] start,
                 int[] stop,
                 int[] step)

      Construct ND slice parameters
      Parameters:
        `shape` -
        `maxShape` - can be null
        `start` - can be null
        `stop` - can be null
        `step` - can be null

  - ### Method Detail

    - #### setSlice

          public void setSlice(int i,
                      Integer start,
                      Integer stop,
                      int step)

      Set slice for given dimension
      Parameters:
        `i` - dimension
        `start` - can be null to imply start of dimension
        `stop` - can be null to imply end of dimension
        `step` -

    - #### setSlice

          public void setSlice(int i,
                      int start,
                      int stop,
                      int step)

      Set slice for given dimension
      Parameters:
        `i` - dimension
        `start` -
        `stop` -
        `step` -

    - #### setSlice

          public void setSlice(int i,
                      Slice slice)

      Set slice for given dimension
      Parameters:
        `i` - dimension
        `slice` -
      Since:
        2.0

    - #### getSourceShape

          public int[] getSourceShape()

      Returns:
        shape of source dataset (this can change for dynamic datasets)

    - #### getMaxShape

          public int[] getMaxShape()

      Returns:
        maximum shape

    - #### isExpanded

          public boolean isExpanded()

      Returns:
        true if slice makes shape larger

    - #### getShape

          public int[] getShape()

      Returns:
        resulting shape (this can change if the start, stop, step arrays are changed)

    - #### getStart

          public int[] getStart()

      Returns:
        start values

    - #### getStop

          public int[] getStop()

      Note stop values are clamped to -1 for negative steps
      Returns:
        stop values

    - #### getStep

          public int[] getStep()

      Returns:
        step values

    - #### isAll

          public boolean isAll()

      Returns:
        true if all of original shape is covered by this slice with positive steps

    - #### flip

          public SliceND flip(int i)

      Flip slice direction in given dimension so slice begins at previous end point, steps in the opposite direction, and finishes at the previous start point
      Parameters:
        `i` - dimension to flip

    - #### flip

          public SliceND flip()

      Flip slice direction in all dimensions so slice begins at previous end point, steps in the opposite direction, and finishes at the previous start point

    - #### convertToSlice

          public Slice[] convertToSlice()

      Convert to a slice array
      Returns:
        a slice array

    - #### clone

          public SliceND clone()

      Overrides:
        `clone` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### createSlice

          public static SliceND createSlice(ILazyDataset data,
                            int[] start,
                            int[] stop)

      Creating slice from dataset
      Parameters:
        `data` -
        `start` -
        `stop` -
      Returns:
        slice

    - #### createSlice

          public static SliceND createSlice(ILazyDataset data,
                            int[] start,
                            int[] stop,
                            int[] step)

      Creating slice from dataset
      Parameters:
        `data` -
        `start` -
        `stop` -
        `step` -
      Returns:
        slice

Copyright © 2017. All rights reserved.