本文整理汇总了Java中io.netty.buffer.ByteBuf.writeDouble方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuf.writeDouble方法的具体用法?Java ByteBuf.writeDouble怎么用?Java ByteBuf.writeDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.buffer.ByteBuf
的用法示例。
在下文中一共展示了ByteBuf.writeDouble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serialize
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
int rows = result.length;
int cols = result[0].length;
buf.writeInt(rows);
buf.writeInt(cols);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
buf.writeDouble(result[i][j]);
}
}
buf.writeInt(partInfo.length);
for (int i = 0; i < partInfo.length; i++) {
buf.writeInt(partInfo[i]);
}
}
示例2: testUpdate
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Test
public void testUpdate() throws Exception {
serverSparseDoubleRow = new ServerSparseDoubleRow(rowId, startCol, endCol);
ByteBuf buf = Unpooled.buffer(16);
buf.writeDouble(0.00);
buf.writeDouble(1.00);
buf.writeDouble(-1.00);
double newValue0 = buf.getDouble(0) + serverSparseDoubleRow.getData().get(0);
double newValue1 = buf.getDouble(8) + serverSparseDoubleRow.getData().get(1);
serverSparseDoubleRow.update(RowType.T_DOUBLE_DENSE, buf, 3);
assertEquals(serverSparseDoubleRow.getData().get(0), newValue0, 0.000);
assertEquals(serverSparseDoubleRow.getData().get(1), newValue1, 0.000);
assertEquals(serverSparseDoubleRow.getData().get(2), -1, 0.000);
serverSparseDoubleRow = new ServerSparseDoubleRow(rowId, startCol, endCol);
buf = Unpooled.buffer(0);
LOG.info(buf);
buf.writeInt(0);
buf.writeDouble(1.00);
buf.writeInt(2);
buf.writeDouble(-2.00);
serverSparseDoubleRow.update(RowType.T_DOUBLE_SPARSE, buf, 2);
assertEquals(serverSparseDoubleRow.getData().get(0), 1, 0.000);
assertEquals(serverSparseDoubleRow.getData().get(1), 0, 0.000);
assertEquals(serverSparseDoubleRow.getData().get(2), -2, 0.000);
}
示例3: testUpdateDoubleSparseToDoubleSparse
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Test
public void testUpdateDoubleSparseToDoubleSparse() throws Exception {
ServerSparseDoubleRow serverSparseDoubleRow =
new ServerSparseDoubleRow(rowId, startCol, endCol);
ByteBuf buf = Unpooled.buffer(16);
buf.writeInt(0);
buf.writeDouble(0.00);
buf.writeInt(1);
buf.writeDouble(1.00);
buf.writeInt(2);
buf.writeDouble(2.00);
rowUpdater.updateDoubleSparseToDoubleSparse(3, buf, serverSparseDoubleRow);
Int2DoubleOpenHashMap hashMap = new Int2DoubleOpenHashMap();
hashMap.addTo(0, 0.00);
hashMap.addTo(1, 1.00);
hashMap.addTo(2, 2.00);
assertEquals(serverSparseDoubleRow.getData(), hashMap);
}
示例4: serialize
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
try {
lock.readLock().lock();
super.serialize(buf);
buf.writeInt(index2ValueMap.size());
ObjectIterator<Long2DoubleMap.Entry> iter = index2ValueMap.long2DoubleEntrySet().fastIterator();
Long2DoubleMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
buf.writeLong(entry.getLongKey());
buf.writeDouble(entry.getDoubleValue());
}
} finally {
lock.readLock().unlock();
}
}
示例5: testDeserialize
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Test
public void testDeserialize() throws Exception {
ByteBuf buf = Unpooled.buffer(16);
buf.writeInt(0);
buf.writeInt(1);
buf.writeLong(2);
buf.writeLong(3);
buf.writeInt(4);
buf.writeInt(3);
buf.writeDouble(-1.0);
buf.writeDouble(-2.0);
buf.writeDouble(-3.0);
serverDenseDoubleRow.deserialize(buf);
assertEquals(serverDenseDoubleRow.getRowId(), 0);
assertEquals(serverDenseDoubleRow.getClock(), 1);
assertEquals(serverDenseDoubleRow.getStartCol(), 2);
assertEquals(serverDenseDoubleRow.getEndCol(), 3);
assertEquals(serverDenseDoubleRow.getRowVersion(), 4);
assertEquals(serverDenseDoubleRow.getData().get(0), -1, 0.0);
assertEquals(serverDenseDoubleRow.getData().get(1), -2, 0.0);
assertEquals(serverDenseDoubleRow.getData().get(2), -3, 0.0);
}
示例6: testWriteTo
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Test
public void testWriteTo() throws Exception {
ByteBuf buf = Unpooled.buffer(16);
buf.writeDouble(0.00);
buf.writeDouble(1.00);
buf.writeDouble(2.00);
serverDenseDoubleRow.update(RowType.T_DOUBLE_DENSE, buf, 3);
DataOutputStream out = new DataOutputStream(new FileOutputStream("data"));
serverDenseDoubleRow.writeTo(out);
out.close();
DataInputStream in = new DataInputStream(new FileInputStream("data"));
assertEquals(in.readDouble(), 0, 0.00);
assertEquals(in.readDouble(), 1, 0.00);
assertEquals(in.readDouble(), 2, 0.00);
in.close();
}
示例7: testReadFrom
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Test
public void testReadFrom() throws Exception {
ByteBuf buf = Unpooled.buffer(16);
buf.writeDouble(10.00);
buf.writeDouble(11.00);
buf.writeDouble(12.00);
serverDenseDoubleRow.update(RowType.T_DOUBLE_DENSE, buf, 3);
DataOutputStream out = new DataOutputStream(new FileOutputStream("data"));
serverDenseDoubleRow.writeTo(out);
out.close();
DataInputStream in = new DataInputStream(new FileInputStream("data"));
ServerDenseDoubleRow newServerDenseDoubleRow =
new ServerDenseDoubleRow(rowId, startCol, endCol);
newServerDenseDoubleRow.readFrom(in);
in.close();
assertEquals(newServerDenseDoubleRow.getData().get(0), serverDenseDoubleRow.getData().get(0),
0.00);
assertEquals(newServerDenseDoubleRow.getData().get(1), serverDenseDoubleRow.getData().get(1),
0.00);
assertEquals(newServerDenseDoubleRow.getData().get(2), serverDenseDoubleRow.getData().get(2),
0.00);
}
示例8: write
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void write( ByteBuf buf ) throws IOException {
writeVarInt( entityId, buf );
writeUUID( uuid, buf );
buf.writeByte( type );
buf.writeDouble( x );
buf.writeDouble( y );
buf.writeDouble( z );
buf.writeByte( toAngle( yaw ) );
buf.writeByte( toAngle( pitch ) );
buf.writeInt( 1 );
buf.writeShort( 1 );
buf.writeShort( 1 );
buf.writeShort( 1 );
}
示例9: serialize
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
buf.writeInt(values.length);
for (double value : values) {
buf.writeDouble(value);
}
}
示例10: toBytes
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void toBytes(ByteBuf buf)
{
buf.writeDouble(this.x);
buf.writeDouble(this.y);
buf.writeDouble(this.z);
buf.writeFloat(this.yaw);
buf.writeFloat(this.pitch);
buf.writeBoolean(this.setX);
buf.writeBoolean(this.setY);
buf.writeBoolean(this.setZ);
buf.writeBoolean(this.setYaw);
buf.writeBoolean(this.setPitch);
}
示例11: writeSpawnData
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void writeSpawnData(ByteBuf buffer) // save extra data on the server
{
buffer.writeDouble(this.ownerX);
buffer.writeDouble(this.ownerY);
buffer.writeDouble(this.ownerZ);
}
示例12: testBufferLen
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Test
public void testBufferLen() throws Exception {
ByteBuf buf = Unpooled.buffer(16);
serverSparseDoubleRow.setClock(8);
buf.writeDouble(0.00);
buf.writeDouble(1.00);
buf.writeDouble(-1.00);
serverSparseDoubleRow.update(RowType.T_DOUBLE_DENSE, buf, 3);
assertEquals(serverSparseDoubleRow.bufferLen(), 20 + 4 + 3 * 12);
}
示例13: writeSpawnData
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void writeSpawnData(ByteBuf buffer) {
buffer.writeDouble(faerieInformation.getMaxHealth());
buffer.writeFloat(faerieInformation.getSize());
buffer.writeInt(faerieInformation.getType());
buffer.writeInt(faerieInformation.getLevel());
buffer.writeInt(faerieInformation.getCurrentExp());
}
示例14: write
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Override
public void write( ByteBuf buf ) throws IOException {
writeVarInt( entityId, buf );
buf.writeDouble( x );
buf.writeDouble( y );
buf.writeDouble( z );
buf.writeByte( toAngle( yaw ) );
buf.writeByte( toAngle( pitch ) );
buf.writeBoolean( onGround );
}
示例15: testUpdateDoubleDenseToDoubleDense
import io.netty.buffer.ByteBuf; //导入方法依赖的package包/类
@Test
public void testUpdateDoubleDenseToDoubleDense() throws Exception {
ServerDenseDoubleRow serverDenseDoubleRow = new ServerDenseDoubleRow(rowId, startCol, endCol);
ByteBuf buf = Unpooled.buffer(16);
buf.writeDouble(0.00);
buf.writeDouble(1.00);
buf.writeDouble(-1.00);
rowUpdater.updateDoubleDenseToDoubleDense(3, buf, serverDenseDoubleRow);
assertEquals(serverDenseDoubleRow.getData().get(0), 0, 0.00);
assertEquals(serverDenseDoubleRow.getData().get(1), 1, 0.00);
assertEquals(serverDenseDoubleRow.getData().get(2), -1, 0.00);
}