use of java.nio.ShortBuffer in project ffx by mjschnie.
the class Signed16BitIntegerMatrixBuf_1 method sendItems.
// Hidden operations.
/**
* {@inheritDoc}
*
* Send as many items as possible from this buffer to the given byte buffer.
* <P>
* The <TT>sendItems()</TT> method must not block the calling thread; if it
* does, all message I/O in MP will be blocked.
*/
protected int sendItems(int i, ByteBuffer buffer) {
ShortBuffer shortbuffer = buffer.asShortBuffer();
int n = 0;
int r = i2r(i);
int row = r + myLowerRow;
int c = i2c(i);
int col = c + myLowerCol;
int ncols = Math.min(myColCount - c, shortbuffer.remaining());
while (r < myRowCount && ncols > 0) {
int[] myMatrix_row = myMatrix[row];
while (c < ncols) {
shortbuffer.put((short) myMatrix_row[col]);
++c;
++col;
}
n += ncols;
++r;
++row;
c = 0;
col = myLowerCol;
ncols = Math.min(myColCount, shortbuffer.remaining());
}
buffer.position(buffer.position() + 2 * n);
return n;
}
use of java.nio.ShortBuffer in project ffx by mjschnie.
the class Unsigned16BitIntegerMatrixBuf_1 method receiveItems.
/**
* {@inheritDoc}
*
* Receive as many items as possible from the given byte buffer to this
* buffer.
* <P>
* The <TT>receiveItems()</TT> method must not block the calling thread; if
* it does, all message I/O in MP will be blocked.
*/
protected int receiveItems(int i, int num, ByteBuffer buffer) {
ShortBuffer shortbuffer = buffer.asShortBuffer();
num = Math.min(num, shortbuffer.remaining());
int n = 0;
int r = i2r(i);
int row = r + myLowerRow;
int c = i2c(i);
int col = c + myLowerCol;
int ncols = Math.min(myColCount - c, num);
while (r < myRowCount && ncols > 0) {
int[] myMatrix_row = myMatrix[row];
for (c = 0; c < ncols; ++c) {
myMatrix_row[col] = shortbuffer.get() & 0xFFFF;
++col;
}
num -= ncols;
n += ncols;
++r;
++row;
col = myLowerCol;
ncols = Math.min(myColCount, num);
}
buffer.position(buffer.position() + 2 * n);
return n;
}
use of java.nio.ShortBuffer in project ffx by mjschnie.
the class Unsigned16BitIntegerMatrixBuf_1 method sendItems.
// Hidden operations.
/**
* {@inheritDoc}
*
* Send as many items as possible from this buffer to the given byte buffer.
* <P>
* The <TT>sendItems()</TT> method must not block the calling thread; if it
* does, all message I/O in MP will be blocked.
*/
protected int sendItems(int i, ByteBuffer buffer) {
ShortBuffer shortbuffer = buffer.asShortBuffer();
int n = 0;
int r = i2r(i);
int row = r + myLowerRow;
int c = i2c(i);
int col = c + myLowerCol;
int ncols = Math.min(myColCount - c, shortbuffer.remaining());
while (r < myRowCount && ncols > 0) {
int[] myMatrix_row = myMatrix[row];
while (c < ncols) {
shortbuffer.put((short) myMatrix_row[col]);
++c;
++col;
}
n += ncols;
++r;
++row;
c = 0;
col = myLowerCol;
ncols = Math.min(myColCount, shortbuffer.remaining());
}
buffer.position(buffer.position() + 2 * n);
return n;
}
use of java.nio.ShortBuffer in project ffx by mjschnie.
the class ShortArrayBuf_1 method sendItems.
// Hidden operations.
/**
* {@inheritDoc}
*
* Send as many items as possible from this buffer to the given byte buffer.
* <P>
* The <TT>sendItems()</TT> method must not block the calling thread; if it
* does, all message I/O in MP will be blocked.
*/
protected int sendItems(int i, ByteBuffer buffer) {
ShortBuffer shortbuffer = buffer.asShortBuffer();
int n = Math.min(myLength - i, shortbuffer.remaining());
shortbuffer.put(myArray, myArrayOffset + i, n);
buffer.position(buffer.position() + 2 * n);
return n;
}
use of java.nio.ShortBuffer in project ffx by mjschnie.
the class ShortMatrixBuf_1 method sendItems.
// Hidden operations.
/**
* {@inheritDoc}
*
* Send as many items as possible from this buffer to the given byte buffer.
* <P>
* The <TT>sendItems()</TT> method must not block the calling thread; if it
* does, all message I/O in MP will be blocked.
*/
protected int sendItems(int i, ByteBuffer buffer) {
ShortBuffer shortbuffer = buffer.asShortBuffer();
int n = 0;
int r = i2r(i);
int row = r + myLowerRow;
int c = i2c(i);
int col = c + myLowerCol;
int ncols = Math.min(myColCount - c, shortbuffer.remaining());
while (r < myRowCount && ncols > 0) {
shortbuffer.put(myMatrix[row], col, ncols);
n += ncols;
++r;
++row;
c = 0;
col = myLowerCol;
ncols = Math.min(myColCount, shortbuffer.remaining());
}
buffer.position(buffer.position() + 2 * n);
return n;
}
Aggregations