|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectucar.multiarray.MultiArrayProxy
This MultiArray implementation wraps another MultiArray and an IndexMap to provide a different view of the wrapped MultiArray. Indices passed to access methods are passed through a chain of mappings.
MultiArray,
IndexMap| Constructor Summary | |
MultiArrayProxy(MultiArray delegate,
IndexMap im)
Construct a new proxy. |
|
| Method Summary | |
void |
copyin(int[] origin,
MultiArray data)
Aggregate write access. |
MultiArray |
copyout(int[] origin,
int[] shape)
Aggregate read access. |
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. |
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()
Returns the shape of the backing MultiArray as transformed by the dimensionsInverseMap() method of
the IndexMap. |
long |
getLong(int[] index)
Get the array element at index, as a long. |
int |
getRank()
Returns the number of dimensions of the backing MultiArray, as transformed by the rankInverseMap() method of
the IndexMap. |
short |
getShort(int[] index)
Get the array element at index, as a short. |
Object |
getStorage()
|
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(String[] args)
|
void |
set(int[] index,
Object value)
Length of index must equal rank() of this. |
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. |
Object |
toArray()
Returns a new array containing all of the elements in this MultiArray. |
Object |
toArray(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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public MultiArrayProxy(MultiArray delegate,
IndexMap im)
delegate - MultiArray backing the proxy view provided.im - IndexMap defining the proxy view.| Method Detail |
public Class getComponentType()
getComponentType in interface MultiArrayInfoClass.getComponentType()public int getRank()
rankInverseMap() method of
the IndexMap.
getRank in interface MultiArrayInfopublic int[] getLengths()
dimensionsInverseMap() method of
the IndexMap.
getLengths in interface MultiArrayInfopublic boolean isUnlimited()
true if and only if the effective dimension
lengths can change.
isUnlimited in interface MultiArrayInfotrue iff this can growpublic boolean isScalar()
true
if and only if the rank is zero.
isScalar in interface MultiArrayInfotrue iff rank == 0
public Object get(int[] index)
throws IOException
Accessor
get in interface Accessorindex - MultiArray index
index
Length of index must equal rank() of this.
Values of index components must be less than corresponding
values from getLengths().
IOException
public boolean getBoolean(int[] index)
throws IOException
Accessor
getBoolean in interface AccessorIOExceptionAccessor.get(int[])
public char getChar(int[] index)
throws IOException
Accessor
getChar in interface AccessorIOExceptionAccessor.get(int[])
public byte getByte(int[] index)
throws IOException
Accessor
getByte in interface AccessorIOExceptionAccessor.get(int[])
public short getShort(int[] index)
throws IOException
Accessor
getShort in interface AccessorIOExceptionAccessor.get(int[])
public int getInt(int[] index)
throws IOException
Accessor
getInt in interface AccessorIOExceptionAccessor.get(int[])
public long getLong(int[] index)
throws IOException
Accessor
getLong in interface AccessorIOExceptionAccessor.get(int[])
public float getFloat(int[] index)
throws IOException
Accessor
getFloat in interface AccessorIOExceptionAccessor.get(int[])
public double getDouble(int[] index)
throws IOException
Accessor
getDouble in interface AccessorIOExceptionAccessor.get(int[])
public void set(int[] index,
Object value)
throws IOException
set in interface Accessorindex - MultiArray indexvalue - the new value.
IOException
public void setBoolean(int[] index,
boolean value)
throws IOException
Accessor
setBoolean in interface AccessorIOExceptionAccessor.set(int[], java.lang.Object)
public void setChar(int[] index,
char value)
throws IOException
Accessor
setChar in interface AccessorIOExceptionAccessor.set(int[], java.lang.Object)
public void setByte(int[] index,
byte value)
throws IOException
Accessor
setByte in interface AccessorIOExceptionAccessor.set(int[], java.lang.Object)
public void setShort(int[] index,
short value)
throws IOException
Accessor
setShort in interface AccessorIOExceptionAccessor.set(int[], java.lang.Object)
public void setInt(int[] index,
int value)
throws IOException
Accessor
setInt in interface AccessorIOExceptionAccessor.set(int[], java.lang.Object)
public void setLong(int[] index,
long value)
throws IOException
Accessor
setLong in interface AccessorIOExceptionAccessor.set(int[], java.lang.Object)
public void setFloat(int[] index,
float value)
throws IOException
Accessor
setFloat in interface AccessorIOExceptionAccessor.set(int[], java.lang.Object)
public void setDouble(int[] index,
double value)
throws IOException
Accessor
setDouble in interface AccessorIOExceptionAccessor.set(int[], java.lang.Object)
public MultiArray copyout(int[] origin,
int[] shape)
throws IOException
AccessorIt 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 Accessororigin - int array specifying the starting index.shape - int array specifying the extents in each
dimension. This becomes the shape of the return.
IOExceptionAccessor.copyout(int[], int[])
public void copyin(int[] origin,
MultiArray data)
throws IOException
AccessorHopefully this member can be optimized in various situations.
assert(origin[ii] + (source.getLengths())[ii]
<= (getLengths())[ii]);
copyin in interface Accessororigin - int array specifying the starting index.data - MultiArray with the same componentType as
this and shape smaller than
this.getLengths() - origin
IOExceptionAccessor.copyin(int[], ucar.multiarray.MultiArray)public Object getStorage()
getStorage in interface MultiArray
public Object toArray()
throws IOException
AccessorThis 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 AccessorIOExceptionTODO: optimize?
public Object toArray(Object dst,
int[] origin,
int[] shape)
throws IOException
AccessorThe 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 AccessorIOExceptionTODO: optimize?public static void main(String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||