public class Array<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
SLICE |
Constructor and Description |
---|
Array()
Do not use this default constructor
|
Array(Array<T> cpy)
Copy constructor makes a copy of an array with all the same values
|
Array(int[] hbounds,
java.lang.Class<?> mainclass,
java.lang.Object container,
T[] initialArr,
java.lang.String name)
Construct a new array with multiple
dimensions of both upper and lower bounds and an initial value
|
Array(int[] hbounds,
java.lang.Class<?> mainclass,
java.lang.Object container,
T initial,
java.lang.String name)
Construct a new array with multiple
dimensions of both upper and lower bounds and an initial value
|
Array(int[] lbounds,
int[] hbounds,
java.lang.Class<?> mainclass,
java.lang.Object container,
T[] initialArr,
java.lang.String name)
Construct a new array with multiple
dimensions of both upper and lower bounds and an initial value
|
Array(int[] lbounds,
int[] hbounds,
java.lang.Class<?> mainclass,
java.lang.Object container,
T initial,
java.lang.String name)
Construct a new array with multiple
dimensions of both upper and lower bounds and an initial value
|
Array(int hbound,
java.lang.Class<?> mainclass,
java.lang.Object container,
T[] initialArr,
java.lang.String name)
Construct a new array with single dimension
with an upper bound and an initial value within another container object.
|
Array(int hbound,
java.lang.Class<?> mainclass,
java.lang.Object container,
T initial,
java.lang.String name)
Construct a new array with single dimension
with an upper bound and an initial value within another container object.
|
Array(int lbound,
int hbound,
java.lang.Class<?> mainclass,
java.lang.Object container,
T[] initialArr,
java.lang.String name)
Construct a new array with single
dimension of both upper and lower bound and an initial value
|
Array(int lbound,
int hbound,
java.lang.Class<?> mainclass,
java.lang.Object container,
T initial,
java.lang.String name)
Construct a new array with single
dimension of both upper and lower bound and an initial value
|
Modifier and Type | Method and Description |
---|---|
Array<T> |
add(Array<T> op)
add - add an array or a scalar (also given as a 1x1 array) to every element of an array
|
void |
assign(Array<T> other)
Assign one array to another, which for us means keep the
indexes the same but assign the contents of the array, thus
a B(2,3) assigned to C(3,2) will have the same number of
elements and the data will be ordered, but won't match up
on specific indexes.
|
void |
assign(T scalar)
Assign a scalar to each element of the array
|
Array<java.math.BigDecimal> |
bigDecimalValue()
bigDecimalValue -- convert an Array
|
Array<java.math.BigInteger> |
bigIntegerValue()
bigIntegerValue -- convert an Array
|
Array<java.lang.Byte> |
byteValue()
byteValue -- convert an Array
|
void |
clear()
Empty an Array
|
Array<T> |
divide(Array<T> op)
divide - matrix divide by an array or a scalar (also given as a 1x1 array)
|
Array<java.lang.Double> |
doubleValue()
doubleValue -- convert an Array
|
boolean |
fill(T newT)
fill - fill the next (empty) element with the given instance.
|
Array<FixedBin> |
fixedBinValue(int digits,
int scale)
fixedBinValue -- convert an Array
|
Array<java.lang.Float> |
floatValue()
floatValue -- convert an Array
|
void |
fromByteArray(byte[] param)
toByteArray - synonym for toBytes()
|
void |
fromBytes(byte[] param)
Return the contents of this array as an array of bytes
|
T |
get(int... idxs)
Retrieve a single value given all dimensions
|
T |
getAbsolute(int absoluteIndex)
Retrieve a single value given an absolute index into the array
where "0" indicates first lowest of each array dimension and
"n-1" is the highest value of each dimension.
|
int |
getDimensions()
Get the number of dimensions in this array
|
int |
getHBound(int index)
Get the upper (higher) bound of dimension number
|
T |
getInitial()
Get the initial value used to set up this Array, often used
to get not the initial value of the class of the elements
|
T[] |
getInitialArr()
Get the initial values used to set up this Array, often used
to get not the initial value of the class of the elements
|
int |
getLBound(int index)
Get the lower bound of dimension number
|
java.lang.String |
getName()
Get the PL/I name of this array for GET/PUT DATA purposes
|
int |
getSize()
Arbitrarily get the number of elements in this array as its 'size'
|
Array<T> |
getSlice(java.lang.Integer... idxs)
Get a slice of an Array, which is a copy of certain
dimensions of the original.
|
Array<java.lang.Integer> |
intValue()
intValue -- convert an Array
|
boolean |
isEmpty()
Return whether the array is empty
|
java.util.Iterator<T> |
iterator()
Return an
iterator<T> for this
note: there is no dimension info available in the return |
Array<java.lang.Long> |
longValue()
longValue -- convert an Array
|
static void |
main(java.lang.String[] args)
main - unit test for Array class
|
Array<T> |
multiply(Array<T> op)
multiply - matrix multipy by an array or a scalar (also given as a 1x1 array)
|
Array<T> |
set(T value,
int... idxs)
Assign a single value given all dimensions
|
Array<T> |
setAbsolute(T value,
int absoluteIndex)
Assign a single value given an absolute index into the array
where "0" indicates first lowest of each array dimension and
"n-1" is the highest value of each dimension.
|
void |
setSlice(Array<T> slice,
java.lang.Object... idxs)
Set a slice of an Array from another Array
|
Array<java.lang.Short> |
shortValue()
shortValue -- convert an Array
|
Array<java.lang.String> |
stringValue()
stringValue -- convert an Array
|
Array<T> |
subtract(Array<T> op)
subtract - subtract an array or a scalar (also given as a 1x1 array) to every element of an array
|
byte[] |
toByteArray()
toByteArray - synonym for toBytes()
|
byte[] |
toBytes()
Return the contents of this array as an array of bytes
|
java.lang.String |
toString()
Runtime conversion from DIM(n,..m) to CHAR(m) VARYING
|
static java.lang.String |
toString(Array<?> inArray,
java.lang.String name,
int type)
Runtime conversion from DIM(n,..m) to CHAR(m) VARYING
|
Array<T> |
valueOf(java.lang.Object value)
an unusual form of assignment of an array is
A(*) = '';
where A is a structure.
|
public static final int SLICE
public Array()
{@link
- Condition#CONDITION SUBSCRIPTRANGE} - alwayspublic Array(int hbound, java.lang.Class<?> mainclass, java.lang.Object container, T initial, java.lang.String name)
hbound
- - the array's high boundmainclass
- - the main class containing container and Allocator() method
or null if T is an immutablecontainer
- - the containing object instance (if an outer class holds the array
being created) or null if T is an immutableinitial
- the initial value of each array element of the same type as the arrayname
- - the PL/I name of this{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an invalid dimension is givenpublic Array(int hbound, java.lang.Class<?> mainclass, java.lang.Object container, T[] initialArr, java.lang.String name)
hbound
- - the array's high boundmainclass
- - the main class containing container and Allocator() method
or null if T is an immutablecontainer
- the containing object instance (if an outer class holds the array
being created) or null if T is an immutable objectinitialArr
- the initial values of each array element of the same type as the arrayname
- - the PL/I name of this{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an invalid dimension is givenpublic Array(int lbound, int hbound, java.lang.Class<?> mainclass, java.lang.Object container, T initial, java.lang.String name)
lbound
- - the array's low boundhbound
- - the array's high boundmainclass
- - the main class containing container and Allocator() method
or null if T is an immutablecontainer
- the containing object instance (if an outer class holds the array
being created) or null if T is an immutable objectinitial
- the initial value of each array element of the same type as the arrayname
- - the PL/I name of this{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an invalid dimension is givenpublic Array(int lbound, int hbound, java.lang.Class<?> mainclass, java.lang.Object container, T[] initialArr, java.lang.String name)
lbound
- - the array's low boundhbound
- - the array's high boundmainclass
- - the main class containing container and Allocator() method
or null if T is an immutablecontainer
- the containing object instance (if an outer class holds the array
being created) or null if T is an immutable objectinitialArr
- the initial values of each array element of the same type as the arrayname
- - the PL/I name of this{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an invalid dimension is givenpublic Array(int[] hbounds, java.lang.Class<?> mainclass, java.lang.Object container, T initial, java.lang.String name)
hbounds
- - the multi-dimensional 's high boundmainclass
- - the main class containing container and Allocator() method
or null if T is an immutablecontainer
- the containing object instance (if an outer class holds the array
being created) or null if T is an immutable objectinitial
- - the initial value of each array element of the same type as the arrayname
- - the PL/I name of this{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an invalid dimension is givenpublic Array(int[] hbounds, java.lang.Class<?> mainclass, java.lang.Object container, T[] initialArr, java.lang.String name)
hbounds
- - the multi-dimensional 's high boundmainclass
- - the main class containing container and Allocator() method
or null if T is an immutablecontainer
- the containing object instance (if an outer class holds the array
being created) or null if T is an immutable objectinitialArr
- - the initial values of each array element of the same type as the arrayname
- - the PL/I name of this{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an invalid dimension is givenpublic Array(int[] lbounds, int[] hbounds, java.lang.Class<?> mainclass, java.lang.Object container, T initial, java.lang.String name)
lbounds
- - the multi-dimensional array's low boundhbounds
- - the multi-dimensional 's high boundmainclass
- - the main class containing container and Allocator() method
or null if T is an immutablecontainer
- the containing object instance (if an outer class holds the array
being created) or null if T is an immutable objectinitial
- - the initial value of each array element of the same type as the arrayname
- - the PL/I name of this{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an invalid dimension is givenpublic Array(int[] lbounds, int[] hbounds, java.lang.Class<?> mainclass, java.lang.Object container, T[] initialArr, java.lang.String name)
lbounds
- - the multi-dimensional array's low boundhbounds
- - the multi-dimensional 's high boundmainclass
- - the main class containing container and Allocator() method
or null if T is an immutablecontainer
- the containing object instance (if an outer class holds the array
being created) or null if T is an immutable objectinitialArr
- - the initial values of each array element of the same type as the arrayname
- - the PL/I name of this{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an invalid dimension is givenpublic boolean fill(T newT)
PL/I: DCL 1 A_GROUP(10), 2 A_MEMBER FIXED BIN(15); DCL MY_ARR(10); Java: ArrayaGroup = new Array (10, new AGroup(), "A_GROUP"); while (aGroup.fill(new AGroup()) ;
newT
- - the "new T()" to fill out this now un-sparse arraypublic T get(int... idxs)
idxs
- - all the indexes of the dimensions of the array{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an index is out of
range for its defined dimension(s)public Array<T> set(T value, int... idxs)
idxs
- - all the indexes of the dimensions of the array{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an index is out of
range for its defined dimension(s)public T getAbsolute(int absoluteIndex)
absoluteIndex
- - an absolute dimension{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an index is out of
range for its defined dimension(s)public Array<T> setAbsolute(T value, int absoluteIndex)
absoluteIndex
- - the absolute index{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an index is out of
range for its defined dimension(s)public int getDimensions()
public int getSize()
public int getHBound(int index)
index
- - the int dimension number (1 base) you're interested inDCL ARR(1:3,1:7)
returns 7 for dimension 2Condition
- SUBSCRIPTRANGE if index is out-of-range for the arraypublic int getLBound(int index)
index
- - the int dimension number (1 base) you're interested inDCL ARR(1:3,1:7) returns 7 for dimension 2
Condition
- SUBSCRIPTRANGE if index is out-of-range for the arraypublic T getInitial()
public T[] getInitialArr()
public java.lang.String getName()
public Array<T> getSlice(java.lang.Integer... idxs)
idxs
- - the array indexes, with its number equal to that of the
number of dimensions defined for the array, and containing objects that
evaluate to a specific index value or null, indicating that the slice
should include all the values of that array.
ex: [1,2,3 defined as Array(3,3) 4,5,6 means getSlice(1,null) give [1,2,3] 7,8,9] means getSlice(null,1) give [1,4,7]
Array
which holds the same values as the original
for the given slice. if two values in idxs have the value SLICE
then a 2-dimensioned array is returned with those values.{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an index is out of
range for its defined dimension(s)public void setSlice(Array<T> slice, java.lang.Object... idxs)
idxs
- - the array indexes specifying all
but the ones that are required to address the array
missing indexes are indicated by SLICE value{@link
- Condition#CONDITION SUBSCRIPTRANGE} - if an index is out of
range for its defined dimension(s)public void assign(Array<T> other)
other
- - the other array to assign to this arraypublic void assign(T scalar)
scalar
- - the scalar to assignpublic Array<T> valueOf(java.lang.Object value)
public Array<java.lang.Long> longValue()
public Array<java.lang.Integer> intValue()
public Array<java.lang.Short> shortValue()
public Array<java.lang.Byte> byteValue()
public Array<java.lang.Float> floatValue()
public Array<java.lang.Double> doubleValue()
public Array<FixedBin> fixedBinValue(int digits, int scale)
public Array<java.math.BigDecimal> bigDecimalValue()
public Array<java.math.BigInteger> bigIntegerValue()
public Array<java.lang.String> stringValue()
public Array<T> add(Array<T> op)
op
- - an array of the same type. if it is a 1x1 dimension array (single element),
then the scalar at op(1,1) is added to each element, otherwise array dimensions must
match and each corresponding element of each array is added.public Array<T> subtract(Array<T> op)
op
- - an array of the same type. if it is a 1x1 dimension array (single element),
then the scalar at op(1,1) is added to each element, otherwise array dimensions must
match and each corresponding element of each array is added.public Array<T> multiply(Array<T> op)
op
- - an array of the same type. if it is a 1x1 dimension array (single element),
then the scalar at op(1,1) is added to each element, otherwise array dimensions must
match and each corresponding element of each array is added.public Array<T> divide(Array<T> op)
op
- - an array of the same type. if it is a 1x1 dimension array (single element),
then the scalar at op(1,1) is added to each element, otherwise array dimensions must
match and each corresponding element of each array is added.public boolean isEmpty()
public void clear()
public java.util.Iterator<T> iterator()
iterator<T>
for this
note: there is no dimension info available in the returnpublic static java.lang.String toString(Array<?> inArray, java.lang.String name, int type)
inArray
- - input Arrayname
- - the name of this array for PUT DATA output
format or null for PUT LIST output formattype
- - 0 untyped, 1 string, 2 bitstringpublic byte[] toBytes()
public byte[] toByteArray()
public void fromBytes(byte[] param)
param
- - byte array to load into the arraypublic void fromByteArray(byte[] param)
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args)