Package ucar.ma2
Class ArrayShort
- java.lang.Object
-
- ucar.ma2.Array
-
- ucar.ma2.ArrayShort
-
- Direct Known Subclasses:
ArrayShort.D0
,ArrayShort.D1
,ArrayShort.D2
,ArrayShort.D3
,ArrayShort.D4
,ArrayShort.D5
,ArrayShort.D6
,ArrayShort.D7
public class ArrayShort extends Array
Concrete implementation of Array specialized for shorts. Data storage is with 1D java array of shorts. issues: what should we do if a conversion loses accuracy? nothing ? Exception ?- See Also:
Array
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ArrayShort.D0
Concrete implementation of Array specialized for shorts, rank 0.static class
ArrayShort.D1
Concrete implementation of Array specialized for shorts, rank 1.static class
ArrayShort.D2
Concrete implementation of Array specialized for shorts, rank 2.static class
ArrayShort.D3
Concrete implementation of Array specialized for shorts, rank 3.static class
ArrayShort.D4
Concrete implementation of Array specialized for shorts, rank 4.static class
ArrayShort.D5
Concrete implementation of Array specialized for shorts, rank 5.static class
ArrayShort.D6
Concrete implementation of Array specialized for shorts, rank 6.static class
ArrayShort.D7
Concrete implementation of Array specialized for shorts, rank 7.
-
Constructor Summary
Constructors Constructor Description ArrayShort(int[] dimensions, boolean isUnsigned)
Create a new Array of type short and the given shape.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
copyFrom1DJavaArray(IndexIterator iter, Object javaArray)
protected void
copyTo1DJavaArray(IndexIterator iter, Object javaArray)
protected Array
createView(Index index)
create new Array with given indexImpl and same backing storeshort
get(Index i)
Get the value at the specified index.boolean
getBoolean(int index)
boolean
getBoolean(Index i)
not legal, throw ForbiddenConversionExceptionbyte
getByte(int index)
byte
getByte(Index i)
Get the array element at the current element of ima, as a byte.char
getChar(int index)
char
getChar(Index i)
Get the array element at the current element of ima, as a char.ByteBuffer
getDataAsByteBuffer()
This gets the data as a ByteBuffer, in correct order.ByteBuffer
getDataAsByteBuffer(ByteOrder order)
double
getDouble(int index)
double
getDouble(Index i)
Get the array element at the current element of ima, as a double.Class
getElementType()
Return the element class typefloat
getFloat(int index)
float
getFloat(Index i)
Get the array element at the current element of ima, as a float.int
getInt(int index)
int
getInt(Index i)
Get the array element at the current element of ima, as a int.long
getLong(int index)
long
getLong(Index i)
Get the array element at the current element of ima, as a long.Object
getObject(int index)
Object
getObject(Index i)
Get the array element at index as an Object.short
getShort(int index)
short
getShort(Index i)
Get the array element at the current element of ima, as a short.Object
getStorage()
Get underlying primitive array storage.void
set(Index i, short value)
Set the value at the specified index.void
setBoolean(int index, boolean value)
void
setBoolean(Index i, boolean value)
not legal, throw ForbiddenConversionExceptionvoid
setByte(int index, byte value)
void
setByte(Index i, byte value)
Set the array element at the current element of ima.void
setChar(int index, char value)
void
setChar(Index i, char value)
Set the array element at the current element of ima.void
setDouble(int index, double value)
void
setDouble(Index i, double value)
Set the array element at the current element of ima.void
setFloat(int index, float value)
void
setFloat(Index i, float value)
Set the array element at the current element of ima.void
setInt(int index, int value)
void
setInt(Index i, int value)
Set the array element at the current element of ima.void
setLong(int index, long value)
void
setLong(Index i, long value)
Set the array element at the current element of ima.void
setObject(int index, Object value)
void
setObject(Index i, Object value)
Set the array element at index to the specified value.void
setShort(int index, short value)
void
setShort(Index i, short value)
Set the array element at the current element of ima.-
Methods inherited from class ucar.ma2.Array
arraycopy, copy, copyTo1DJavaArray, copyToNDJavaArray, factory, factory, factory, factory, factoryConstant, factoryCopy, flip, get1DJavaArray, get1DJavaArray, getDataAsByteBuffer, getDataType, getIndex, getIndexIterator, getRangeIterator, getRank, getShape, getSize, getSizeBytes, hasNext, isConstant, isUnsigned, isVlen, makeArray, makeArray, makeArray, makeArrayRankPlusOne, makeFromJavaArray, makeFromJavaArray, makeObjectArray, makeVlenArray, next, nextBoolean, nextByte, nextChar, nextDouble, nextFloat, nextInt, nextLong, nextShort, permute, reduce, reduce, resetLocalIterator, reshape, reshapeNoCopy, section, section, section, sectionNoReduce, sectionNoReduce, shapeToString, slice, toString, transpose
-
-
-
-
Method Detail
-
createView
protected Array createView(Index index)
create new Array with given indexImpl and same backing store- Specified by:
createView
in classArray
- Parameters:
index
- use this Index- Returns:
- a view of the Array using the given Index
-
getStorage
public Object getStorage()
Description copied from class:Array
Get underlying primitive array storage. Exposed for efficiency, use at your own risk.- Specified by:
getStorage
in classArray
- Returns:
- underlying primitive array storage
-
copyFrom1DJavaArray
protected void copyFrom1DJavaArray(IndexIterator iter, Object javaArray)
- Specified by:
copyFrom1DJavaArray
in classArray
-
copyTo1DJavaArray
protected void copyTo1DJavaArray(IndexIterator iter, Object javaArray)
- Specified by:
copyTo1DJavaArray
in classArray
-
getDataAsByteBuffer
public ByteBuffer getDataAsByteBuffer()
Description copied from class:Array
This gets the data as a ByteBuffer, in correct order. It avoids copying if possible. Only for numeric types (byte, short, int, long, double, float)- Overrides:
getDataAsByteBuffer
in classArray
- Returns:
- equivalent data in a ByteBuffer
-
getDataAsByteBuffer
public ByteBuffer getDataAsByteBuffer(ByteOrder order)
- Overrides:
getDataAsByteBuffer
in classArray
-
getElementType
public Class getElementType()
Return the element class type- Specified by:
getElementType
in classArray
- Returns:
- the class of the element
-
get
public short get(Index i)
Get the value at the specified index.- Parameters:
i
- the index- Returns:
- the value at the specified index.
-
set
public void set(Index i, short value)
Set the value at the specified index.- Parameters:
i
- the indexvalue
- set to this value
-
getDouble
public double getDouble(Index i)
Description copied from class:Array
Get the array element at the current element of ima, as a double.
-
setDouble
public void setDouble(Index i, double value)
Description copied from class:Array
Set the array element at the current element of ima.
-
getFloat
public float getFloat(Index i)
Description copied from class:Array
Get the array element at the current element of ima, as a float.
-
setFloat
public void setFloat(Index i, float value)
Description copied from class:Array
Set the array element at the current element of ima.
-
getLong
public long getLong(Index i)
Description copied from class:Array
Get the array element at the current element of ima, as a long.
-
setLong
public void setLong(Index i, long value)
Description copied from class:Array
Set the array element at the current element of ima.
-
getInt
public int getInt(Index i)
Description copied from class:Array
Get the array element at the current element of ima, as a int.
-
setInt
public void setInt(Index i, int value)
Description copied from class:Array
Set the array element at the current element of ima.
-
getShort
public short getShort(Index i)
Description copied from class:Array
Get the array element at the current element of ima, as a short.
-
setShort
public void setShort(Index i, short value)
Description copied from class:Array
Set the array element at the current element of ima.
-
getByte
public byte getByte(Index i)
Description copied from class:Array
Get the array element at the current element of ima, as a byte.
-
setByte
public void setByte(Index i, byte value)
Description copied from class:Array
Set the array element at the current element of ima.
-
getChar
public char getChar(Index i)
Description copied from class:Array
Get the array element at the current element of ima, as a char.
-
setChar
public void setChar(Index i, char value)
Description copied from class:Array
Set the array element at the current element of ima.
-
getBoolean
public boolean getBoolean(Index i)
not legal, throw ForbiddenConversionException- Specified by:
getBoolean
in classArray
- Parameters:
i
- Index with current element set- Returns:
- value at
index
cast to boolean if necessary.
-
setBoolean
public void setBoolean(Index i, boolean value)
not legal, throw ForbiddenConversionException- Specified by:
setBoolean
in classArray
- Parameters:
i
- Index with current element setvalue
- the new value; cast to underlying data type if necessary.
-
getObject
public Object getObject(Index i)
Description copied from class:Array
Get the array element at index as an Object. The returned value is wrapped in an object, eg Double for double
-
setObject
public void setObject(Index i, Object value)
Description copied from class:Array
Set the array element at index to the specified value. the value must be passed wrapped in the appropriate Object (eg Double for double)
-
getBoolean
public boolean getBoolean(int index)
- Specified by:
getBoolean
in classArray
-
setBoolean
public void setBoolean(int index, boolean value)
- Specified by:
setBoolean
in classArray
-
-