本文整理匯總了Java中java.nio.LongBuffer.remaining方法的典型用法代碼示例。如果您正苦於以下問題:Java LongBuffer.remaining方法的具體用法?Java LongBuffer.remaining怎麽用?Java LongBuffer.remaining使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.LongBuffer
的用法示例。
在下文中一共展示了LongBuffer.remaining方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: LongDiskArrayAccess
import java.nio.LongBuffer; //導入方法依賴的package包/類
public LongDiskArrayAccess(int mode, long fileOffset, int length)
throws ApfloatRuntimeException
{
super(new long[length], 0, length);
this.mode = mode;
this.fileOffset = fileOffset;
if ((mode & READ) != 0)
{
final long[] array = getLongData();
WritableByteChannel out = new WritableByteChannel()
{
public int write(ByteBuffer buffer)
{
LongBuffer src = buffer.asLongBuffer();
int readLength = src.remaining();
src.get(array, this.readPosition, readLength);
this.readPosition += readLength;
buffer.position(buffer.position() + readLength * 8);
return readLength * 8;
}
public void close() {}
public boolean isOpen() { return true; }
private int readPosition = 0;
};
transferTo(out, fileOffset * 8, (long) length * 8);
}
}
示例2: close
import java.nio.LongBuffer; //導入方法依賴的package包/類
public void close()
throws ApfloatRuntimeException
{
if ((this.mode & WRITE) != 0 && getData() != null)
{
final long[] array = getLongData();
ReadableByteChannel in = new ReadableByteChannel()
{
public int read(ByteBuffer buffer)
{
LongBuffer dst = buffer.asLongBuffer();
int writeLength = dst.remaining();
dst.put(array, this.writePosition, writeLength);
this.writePosition += writeLength;
buffer.position(buffer.position() + writeLength * 8);
return writeLength * 8;
}
public void close() {}
public boolean isOpen() { return true; }
private int writePosition = 0;
};
transferFrom(in, this.fileOffset * 8, (long) array.length * 8);
}
super.close();
}
示例3: valueOf
import java.nio.LongBuffer; //導入方法依賴的package包/類
/**
* Returns a {@code BitSet} corresponding to {@code longBuffer}, interpreted as a little-endian
* sequence of bits. This method does not alter the {@code LongBuffer}.
* @since 1.7
*/
public static BitSet valueOf(LongBuffer longBuffer) {
// The bulk get would mutate LongBuffer (even if we reset position later), and it's not
// clear that's allowed. My assumption is that it's the long[] variant that's the common
// case anyway, so copy the buffer into a long[].
long[] longs = new long[longBuffer.remaining()];
for (int i = 0; i < longs.length; ++i) {
longs[i] = longBuffer.get(longBuffer.position() + i);
}
return BitSet.valueOf(longs);
}
示例4: byteArray2IntArray
import java.nio.LongBuffer; //導入方法依賴的package包/類
public int[] byteArray2IntArray(byte[] byteArray){
ByteBuffer bb=
ByteBuffer.wrap(byteArray)
.order(ByteOrder.BIG_ENDIAN);
bb.rewind();
LongBuffer lb = bb.asLongBuffer();
lb.rewind();
long[] larray = new long[lb.remaining()];
lb.get(larray);
int[] iarray=new int[larray.length/3*4];
for (int idx=0;idx<larray.length;idx++){
iarray[idx] = (int)larray[idx];
}
return iarray;
}
示例5: valueOf
import java.nio.LongBuffer; //導入方法依賴的package包/類
/**
* Returns a new bit set containing all the bits in the given long
* buffer between its position and limit.
*
* <p>More precisely,
* <br>{@code BitSet.valueOf(lb).get(n) == ((lb.get(lb.position()+n/64) & (1L<<(n%64))) != 0)}
* <br>for all {@code n < 64 * lb.remaining()}.
*
* <p>The long buffer is not modified by this method, and no
* reference to the buffer is retained by the bit set.
*
* @param lb a long buffer containing a little-endian representation
* of a sequence of bits between its position and limit, to be
* used as the initial bits of the new bit set
* @return a {@code BitSet} containing all the bits in the buffer in the
* specified range
* @since 1.7
*/
public static BitSet valueOf(LongBuffer lb) {
lb = lb.slice();
int n;
for (n = lb.remaining(); n > 0 && lb.get(n - 1) == 0; n--)
;
long[] words = new long[n];
lb.get(words);
return new BitSet(words);
}
示例6: valueOf
import java.nio.LongBuffer; //導入方法依賴的package包/類
/**
* Returns a new bit set containing all the bits in the given long
* buffer between its position and limit.
*
* <p>More precisely,
* <br>{@code BitSetWithMask.valueOf(lb).get(n) == ((lb.get(lb.position()+n/64) & (1L<<(n%64))) != 0)}
* <br>for all {@code n < 64 * lb.remaining()}.
*
* <p>The long buffer is not modified by this method, and no
* reference to the buffer is retained by the bit set.
*
* @param lb a long buffer containing a little-endian representation
* of a sequence of bits between its position and limit, to be
* used as the initial bits of the new bit set
* @return a {@code BitSetWithMask} containing all the bits in the buffer in the
* specified range
* @since 1.7
*/
public static BitSetWithMask valueOf(LongBuffer lb) {
lb = lb.slice();
int n;
for (n = lb.remaining(); n > 0 && lb.get(n - 1) == 0; n--)
;
long[] words = new long[n];
lb.get(words);
return new BitSetWithMask(words);
}