public class BshArray
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Class<?> |
commonType(java.lang.Class<?> baseType,
java.lang.Object fromValue,
java.util.function.IntSupplier length)
Find a more specific type if the element type is Object.class.
|
static java.lang.Object |
concat(java.util.List<?> lhs,
java.util.List<?> rhs)
Concatenate two lists.
|
static java.lang.Object |
concat(java.lang.Object lhs,
java.lang.Object rhs)
Concatenate two arrays.
|
static int[] |
dimensions(java.lang.Object arr)
Collect dimensions array of supplied array object.
|
static java.lang.Object |
getIndex(java.lang.Object array,
int index)
Get object from array or list at index.
|
static java.lang.Object |
repeat(java.util.List<java.lang.Object> list,
int times)
Repeat the contents of a list a number of times.
|
static java.lang.Object |
repeat(java.lang.Object arr,
int times)
Repeat the contents of an array a number of times.
|
static void |
setIndex(java.lang.Object array,
int index,
java.lang.Object val)
Set element value of array or list at index.
|
static java.lang.Object |
slice(java.util.List<java.lang.Object> list,
int from,
int to,
int step)
Slice the supplied list for range and step.
|
static java.lang.Object |
slice(java.lang.Object arr,
int from,
int to,
int step)
Slice the supplied array for range and step.
|
public static java.lang.Object getIndex(java.lang.Object array,
int index)
throws UtilTargetError
array - to retrieve fromindex - of the element to retrieveUtilTargetError - wrapped Index out of boundspublic static void setIndex(java.lang.Object array,
int index,
java.lang.Object val)
throws bsh.ReflectError,
UtilTargetError
array - to set value for.index - of the element to setval - the value to setUtilTargetError - wrapped target exceptionsbsh.ReflectErrorpublic static java.lang.Object slice(java.util.List<java.lang.Object> list,
int from,
int to,
int step)
list - to slicefrom - start index inclusiveto - to index exclusivestep - size of step or 0 if no steppublic static java.lang.Object slice(java.lang.Object arr,
int from,
int to,
int step)
arr - to slicefrom - start index inclusiveto - to index exclusivestep - size of step or 0 if no steppublic static java.lang.Object repeat(java.util.List<java.lang.Object> list,
int times)
list - the list to repeattimes - number of repetitionspublic static java.lang.Object repeat(java.lang.Object arr,
int times)
arr - the array object to repeattimes - number of repetitionspublic static java.lang.Object concat(java.util.List<?> lhs,
java.util.List<?> rhs)
lhs - 1st listrhs - 2nd listpublic static java.lang.Object concat(java.lang.Object lhs,
java.lang.Object rhs)
throws UtilEvalError
lhs - 1st arrayrhs - 2nd arrayUtilEvalError - for inconsistent dimensions.public static int[] dimensions(java.lang.Object arr)
arr - to inspectpublic static java.lang.Class<?> commonType(java.lang.Class<?> baseType,
java.lang.Object fromValue,
java.util.function.IntSupplier length)
baseType - the element typefromValue - the array to inspectlength - the length of the array