本文整理汇总了Java中java.nio.DoubleBuffer.limit方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleBuffer.limit方法的具体用法?Java DoubleBuffer.limit怎么用?Java DoubleBuffer.limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.DoubleBuffer
的用法示例。
在下文中一共展示了DoubleBuffer.limit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDoubleGet
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@Test(dataProvider = "doubleViewProvider")
public void testDoubleGet(String desc, IntFunction<ByteBuffer> fbb,
Function<ByteBuffer, DoubleBuffer> fbi) {
ByteBuffer bb = allocate(fbb);
DoubleBuffer vb = fbi.apply(bb);
int o = bb.position();
for (int i = 0; i < vb.limit(); i++) {
double fromBytes = getDoubleFromBytes(bb, o + i * 8);
double fromMethodView = bb.getDouble(o + i * 8);
assertValues(i, fromBytes, fromMethodView, bb);
double fromBufferView = vb.get(i);
assertValues(i, fromMethodView, fromBufferView, bb, vb);
}
for (int i = 0; i < vb.limit(); i++) {
double v = getDoubleFromBytes(bb, o + i * 8);
double a = bb.getDouble();
assertValues(i, v, a, bb);
double b = vb.get();
assertValues(i, a, b, bb, vb);
}
}
示例2: createDoubleBuffer
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
/**
* Create a new DoubleBuffer of an appropriate size to hold the specified
* number of doubles only if the given buffer if not already the right size.
*
* @param buf
* the buffer to first check and rewind
* @param size
* number of doubles that need to be held by the newly created
* buffer
* @return the requested new DoubleBuffer
*/
public static DoubleBuffer createDoubleBuffer(DoubleBuffer buf, int size) {
if (buf != null && buf.limit() == size) {
buf.rewind();
return buf;
}
buf = createDoubleBuffer(size);
return buf;
}