public class BufferIterator
extends java.lang.Object
implements java.util.Iterator
This class provides a thin convenience wrapper around
ChunkStepper, which is itself a simple class which steps
from zero to a given limit in chunks. The only additional functionality
provided by a BufferIterator is that it will ensure a
suitable primitive buffer is available at each step, and (since the
next method actually returns something, namely the buffer),
it implements the Iterator interface which
ChunkStepper does not.
A typical use of BufferIterator is as follows:
ArrayAccess acc = ndarray.getAccess();
for ( BufferIterator bufIt = new BufferIterator( npix, Type.DOUBLE );
bufIt.hasNext(); ) {
double[] buf = (double[]) bIt.next();
acc.read( buf, 0, buf.length );
doStuff( buf );
}
ChunkStepper| Constructor and Description |
|---|
BufferIterator(long length)
Create a new BufferIterator with a default chunk size.
|
BufferIterator(long length,
Type type,
int chunkSize)
Create a new BufferIterator with a given chunk size.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getBase()
The offset of the base of the chunk most recently returned by
next.
|
boolean |
hasNext()
See if iteration has finished.
|
java.lang.Object |
next()
Returns a primitive buffer of this object's type, with a length
matching that of this chunk.
|
void |
remove()
Remove functionality is not implemented by this class.
|
public BufferIterator(long length,
Type type,
int chunkSize)
length - the total number of elements to iterate overtype - the type of the primitive buffer which the
next method will return at each iterationchunkSize - the size of buffer which will be used (except
perhaps for the last chunk)java.lang.IllegalArgumentException - if chunkSize<=0
or length<0public BufferIterator(long length)
length - the total number of elements to iterate overpublic java.lang.Object next()
next in interface java.util.IteratorNoSuchElementException - if hasNext would return falsepublic boolean hasNext()
hasNext in interface java.util.Iteratorpublic void remove()
remove in interface java.util.Iteratorjava.lang.UnsupportedOperationException - alwayspublic long getBase()
java.lang.IllegalStateException - if called before the first call of
nextCopyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.