public class Slice extends Object implements Cloneable, Serializable
Constructor and Description |
---|
Slice() |
Slice(Integer stop)
Default to starting at 0 with steps of 1
|
Slice(Integer start,
Integer stop)
Default to steps of 1
|
Slice(Integer start,
Integer stop,
Integer step) |
Modifier and Type | Method and Description |
---|---|
static void |
appendSliceToString(StringBuilder s,
int len,
int beg,
int end,
int del)
Append string representation of slice
|
Slice |
clone() |
static void |
convertFromSlice(Slice[] slice,
int[] shape,
int[] start,
int[] stop,
int[] step)
Populate given start, stop, step arrays from given slice array
|
static Slice[] |
convertFromString(String sliceString)
Convert a string to a slice array
|
static Slice[] |
convertToSlice(int[] start,
int[] stop,
int[] step)
Convert from a set of integer arrays to a slice array
|
static String |
createString(int[] shape,
int[] start,
int[] stop,
int[] step)
Create a string representing the slice taken from given shape
|
static String |
createString(Slice... slices) |
Slice |
flip()
Flip slice direction so slice begins at previous end point, steps
in the opposite direction, and finishes at the previous start point .
|
int |
getEnd() |
int |
getLength() |
int |
getNumSteps() |
int |
getNumSteps(int beg,
int end) |
int |
getPosition(int n)
Get position of n-th step in slice
|
Integer |
getStart() |
int |
getStep() |
Integer |
getStop() |
boolean |
isSliceComplete() |
Slice |
setLength(int length)
Set maximum value of slice
|
boolean |
setPosition(int beg)
Set start and end from implied number of steps.
|
void |
setStart(Integer start)
Set starting position of slice
|
void |
setStep(int step)
Set step size of slice
|
void |
setStop(Integer stop)
Set stopping position of slice
|
String |
toString() |
public Slice()
public Slice(Integer stop)
stop
- if null, then default to whatever shape is when convertedpublic Slice(Integer start, Integer stop)
start
- if null, then default to 0stop
- if null, then default to whatever shape is when convertedpublic Slice setLength(int length)
length
- public boolean isSliceComplete()
public int getLength()
public int getStep()
public void setStart(Integer start)
start
- (can be null)public void setStop(Integer stop)
stop
- (can be null)public boolean setPosition(int beg)
beg
- public int getPosition(int n)
n
- public void setStep(int step)
step
- public static void appendSliceToString(StringBuilder s, int len, int beg, int end, int del)
s
- len
- beg
- end
- del
- public int getNumSteps()
public int getNumSteps(int beg, int end)
beg
- end
- (exclusive)public int getEnd()
public Slice flip()
Note the stop value may not be preserved across two flips
public static void convertFromSlice(Slice[] slice, int[] shape, int[] start, int[] stop, int[] step)
shape
- start
- stop
- step
- slice
- public static Slice[] convertToSlice(int[] start, int[] stop, int[] step)
start
- stop
- step
- public static Slice[] convertFromString(String sliceString)
sliceString
- public static String createString(int[] shape, int[] start, int[] stop, int[] step)
shape
- start
- stop
- step
- public static String createString(Slice... slices)
slices
- Copyright © 2017. All rights reserved.