|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Layout
Iterator to read/write subsets of a multidimensional array, finding the contiguous chunks. The iteration is monotonic in both src and dest positions.
Example for Integers:
int[] read( Layout index, int[] src) {
int[] dest = new int[index.getTotalNelems()];
while (index.hasNext()) {
Layout.Chunk chunk = index.next();
System.arraycopy(src, chunk.getSrcElem(), dest, chunk.getDestElem(), chunk.getNelems());
}
return dest;
}
int[] read( Layout index, RandomAccessFile raf) {
int[] dest = new int[index.getTotalNelems()];
while (index.hasNext()) {
Layout.Chunk chunk = index.next();
raf.seek( chunk.getSrcPos());
raf.readInt(dest, chunk.getDestElem(), chunk.getNelems());
}
return dest;
}
// note src and dest misnamed
void write( Layout index, int[] src, RandomAccessFile raf) {
while (index.hasNext()) {
Layout.Chunk chunk = index.next();
raf.seek ( chunk.getSrcPos());
for (int k=0; k
- Since:
- Jan 2, 2008
- Author:
- caron
Nested Class Summary
static interface
Layout.Chunk
A chunk of data that is contiguous in both the source and destination.
Method Summary
int
getElemSize()
Get size of each element in bytes.
long
getTotalNelems()
Get total number of elements in the wanted subset.
boolean
hasNext()
Is there more to do
Layout.Chunk
next()
Get the next chunk
Method Detail
getTotalNelems
long getTotalNelems()
- Get total number of elements in the wanted subset.
- Returns:
- total number of elements in the wanted subset.
getElemSize
int getElemSize()
- Get size of each element in bytes.
- Returns:
- size of each element in bytes.
hasNext
boolean hasNext()
- Is there more to do
- Returns:
- true if theres more to do
next
Layout.Chunk next()
throws IOException
- Get the next chunk
- Returns:
- next chunk, or null if !hasNext()
- Throws:
IOException - on i/o error
Overview
Package
Class
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.