Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://angel.cs.msu.su/projects/system/toolsdoc/netcdf_java/ucar/multiarray/MultiArrayImpl.html
Дата изменения: Tue Dec 28 20:59:06 2004 Дата индексирования: Sun Apr 10 00:17:11 2016 Кодировка: |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ucar.multiarray.MultiArrayImpl
A concrete, space efficent implementation of the MultiArray interface.
MultiArray
, Serialized FormField Summary | |
java.lang.Object |
storage
The actual storage. |
Constructor Summary | |
MultiArrayImpl(java.lang.Class componentType,
int[] dimensions)
Create a new MultiArray of the given componentType and shape. |
|
MultiArrayImpl(int[] lengths,
int[] products,
java.lang.Object storage)
Create a new MultiArrayImple of the given shape accessing externally created storage. |
|
MultiArrayImpl(int[] lengths,
java.lang.Object storage)
Create a new MultiArrayImpl of the given shape accessing externally created storage. |
|
MultiArrayImpl(MultiArray ma)
A copy constructor. |
Method Summary | |
java.lang.Object |
clone()
|
void |
copyin(int[] origin,
MultiArray data)
Aggregate write access. |
void |
copyin(int[] origin,
MultiArrayImpl src)
Version copyin specialized and optimized for
MultiArrayImpl. |
MultiArray |
copyout(int[] origin,
int[] shape)
Aggregate read access. |
static java.lang.Object |
fixDest(java.lang.Object dst,
int lengthNeeded,
java.lang.Class defaultComponentType)
|
java.lang.Object |
get(int[] index)
Get (read) the array element at index. |
boolean |
getBoolean(int[] index)
Get the array element at index, as a boolean. |
byte |
getByte(int[] index)
Get the array element at index, as a byte. |
char |
getChar(int[] index)
Get the array element at index, as a char. |
java.lang.Class |
getComponentType()
Returns the Class object representing the component type of the array. |
double |
getDouble(int[] index)
Get the array element at index, as a double. |
float |
getFloat(int[] index)
Get the array element at index, as a float. |
int |
getInt(int[] index)
Get the array element at index, as an int. |
int[] |
getLengths()
Discover the dimensions of this MultiArray. |
long |
getLong(int[] index)
Get the array element at index, as a long. |
int |
getRank()
Returns the number of dimensions of the array. |
short |
getShort(int[] index)
Get the array element at index, as a short. |
int |
indexMap(int[] index)
Convert index vector into integer index into storage. |
boolean |
isScalar()
Convenience interface; return true
if and only if the rank is zero. |
boolean |
isUnlimited()
Returns true if and only if the effective dimension
lengths can change. |
static void |
main(java.lang.String[] args)
|
static int |
numberOfElements(int[] dimensions)
Used to figure out how storage is required for a given shape. |
static int |
numberOfElements(int[] dimensions,
int[] products)
Used to figure out how storage is required for a given shape, retaining intermediate products. |
void |
set(int[] index,
java.lang.Object value)
Set (modify, write) the array element at index to the specified value. |
void |
setBoolean(int[] index,
boolean value)
Set the array element at index to the specified boolean value. |
void |
setByte(int[] index,
byte value)
Set the array element at index to the specified byte value. |
void |
setChar(int[] index,
char value)
Set the array element at index to the specified char value. |
void |
setDouble(int[] index,
double value)
Set the array element at index to the specified double value. |
void |
setFloat(int[] index,
float value)
Set the array element at index to the specified float value. |
void |
setInt(int[] index,
int value)
Set the array element at index to the specified int value. |
void |
setLong(int[] index,
long value)
Set the array element at index to the specified long value. |
void |
setShort(int[] index,
short value)
Set the array element at index to the specified short value. |
java.lang.Object |
toArray()
Returns a new array containing all of the elements in this MultiArray. |
java.lang.Object |
toArray(java.lang.Object dst,
int[] origin,
int[] shape)
Returns an array containing elements of this MultiArray specified by origin and shape, possibly converting the component type. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public final java.lang.Object storage
Constructor Detail |
public MultiArrayImpl(java.lang.Class componentType, int[] dimensions)
componentType
- Class of the primitives or objects to
be contained.dimensions
- the shape of the MultiArray.
dimensions.length determines the rank of the new MultiArray.public MultiArrayImpl(MultiArray ma) throws java.io.IOException
Create a new MultiArray with the same componentType and shape as the argument Storage for values is allocated and owned by this, and the values are initialized to the values of the argument.
ma
- the MultiArray to copy.public MultiArrayImpl(int[] lengths, java.lang.Object storage)
lengths
- the shape of the MultiArray.storage
- array Object which is storagepublic MultiArrayImpl(int[] lengths, int[] products, java.lang.Object storage)
lengths
- describing the shape of the MultiArray.products
- right-to-left accumulated sizes.storage
- array Object which is storageMethod Detail |
public static int numberOfElements(int[] dimensions)
dimensions
- the shape.public static int numberOfElements(int[] dimensions, int[] products)
dimensions
- the shape.products
- modified upon return to contain
the intermediate productspublic java.lang.Class getComponentType()
MultiArrayInfo
getComponentType
in interface MultiArrayInfo
MultiArrayInfo.getComponentType()
public int getRank()
MultiArrayInfo
getRank
in interface MultiArrayInfo
MultiArrayInfo.getRank()
public int[] getLengths()
MultiArrayInfo
getLengths
in interface MultiArrayInfo
MultiArrayInfo.getLengths()
public boolean isUnlimited()
MultiArrayInfo
true
if and only if the effective dimension
lengths can change. For example, if this were implemented by
a java.util.Vector.isUnlimited
in interface MultiArrayInfo
MultiArrayInfo.isUnlimited()
public boolean isScalar()
MultiArrayInfo
true
if and only if the rank is zero.isScalar
in interface MultiArrayInfo
MultiArrayInfo.isScalar()
public java.lang.Object get(int[] index)
Accessor
get
in interface Accessor
Accessor.get(int[])
public boolean getBoolean(int[] index)
Accessor
getBoolean
in interface Accessor
Accessor.getBoolean(int[])
public char getChar(int[] index)
Accessor
getChar
in interface Accessor
Accessor.getChar(int[])
public byte getByte(int[] index)
Accessor
getByte
in interface Accessor
Accessor.getByte(int[])
public short getShort(int[] index)
Accessor
getShort
in interface Accessor
Accessor.getShort(int[])
public int getInt(int[] index)
Accessor
getInt
in interface Accessor
Accessor.getInt(int[])
public long getLong(int[] index)
Accessor
getLong
in interface Accessor
Accessor.getLong(int[])
public float getFloat(int[] index)
Accessor
getFloat
in interface Accessor
Accessor.getFloat(int[])
public double getDouble(int[] index)
Accessor
getDouble
in interface Accessor
Accessor.getDouble(int[])
public void set(int[] index, java.lang.Object value)
Accessor
set
in interface Accessor
Accessor.set(int[], java.lang.Object)
public void setBoolean(int[] index, boolean value)
Accessor
setBoolean
in interface Accessor
Accessor.setBoolean(int[], boolean)
public void setChar(int[] index, char value)
Accessor
setChar
in interface Accessor
Accessor.setChar(int[], char)
public void setByte(int[] index, byte value)
Accessor
setByte
in interface Accessor
Accessor.setByte(int[], byte)
public void setShort(int[] index, short value)
Accessor
setShort
in interface Accessor
Accessor.setShort(int[], short)
public void setInt(int[] index, int value)
Accessor
setInt
in interface Accessor
Accessor.setInt(int[], int)
public void setLong(int[] index, long value)
Accessor
setLong
in interface Accessor
Accessor.setLong(int[], long)
public void setFloat(int[] index, float value)
Accessor
setFloat
in interface Accessor
Accessor.setFloat(int[], float)
public void setDouble(int[] index, double value)
Accessor
setDouble
in interface Accessor
Accessor.setDouble(int[], double)
public MultiArray copyout(int[] origin, int[] shape)
Accessor
It is easier to implement than to specify :-).
The main reason to implement this instead of using the equivalent proxy is for remote or file access.
assert(origin[ii] + shape[ii] <= lengths[ii]);
copyout
in interface Accessor
Accessor.copyout(int[], int[])
public void copyin(int[] origin, MultiArrayImpl src)
copyin
specialized and optimized for
MultiArrayImpl.Accessor.copyin(int[], ucar.multiarray.MultiArray)
public void copyin(int[] origin, MultiArray data) throws java.io.IOException
Accessor
Hopefully this member can be optimized in various situations.
assert(origin[ii] + (source.getLengths())[ii]
<= (getLengths())[ii]);
copyin
in interface Accessor
Accessor.copyin(int[], ucar.multiarray.MultiArray)
public static java.lang.Object fixDest(java.lang.Object dst, int lengthNeeded, java.lang.Class defaultComponentType)
public java.lang.Object toArray()
Accessor
This method acts as bridge between array-based and MultiArray-based APIs.
This method is functionally equivalent to
Object anArray = Array.newInstance(getComponentType(), 1); int [] origin = new int[getRank()] int [] shape = getDimensions(); return toArray(anArray, origin, shape);
toArray
in interface Accessor
Accessor.toArray()
public java.lang.Object toArray(java.lang.Object dst, int[] origin, int[] shape)
Accessor
The anArray argument should be an array. If it is large enough to contain the output, it is used and no new storage is allocated. Otherwise, new storage is allocated with the same component type as the argument, and the data is copied into it.
This method acts as bridge between array-based and MultiArray-based APIs.
This method is similar to copyout(origin, shape).toArray(), but avoids a copy operation and (potentially) an allocation.
NOTE: Implementation of type conversion is deferred until
JDK 1.2. Currently, the componentType of anArray
must be the same as this
toArray
in interface Accessor
Accessor.toArray()
public java.lang.Object clone()
clone
in class java.lang.Object
Object.clone()
public int indexMap(int[] index)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |