當前位置: 首頁>>代碼示例>>Java>>正文


Java ByteBuf.writeDouble方法代碼示例

本文整理匯總了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]);
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:19,代碼來源:FullPartitionAggrResult.java

示例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);
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:27,代碼來源:ServerSparseDoubleRowTest.java

示例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);
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:19,代碼來源:DefaultRowUpdaterTest.java

示例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();
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:19,代碼來源:ServerSparseDoubleLongKeyRow.java

示例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);
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:23,代碼來源:ServerDenseDoubleRowTest.java

示例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();
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:17,代碼來源:ServerDenseDoubleRowTest.java

示例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);
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:23,代碼來源:ServerDenseDoubleRowTest.java

示例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 );
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:16,代碼來源:MessageS00SpawnObject.java

示例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);
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:9,代碼來源:FullUpdateParam.java

示例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);
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:16,代碼來源:AbsoluteMovementCommandsImplementation.java

示例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);
   }
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:8,代碼來源:EnderAccelerator.java

示例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);
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:11,代碼來源:ServerSparseDoubleRowTest.java

示例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());
}
 
開發者ID:BenjaminSutter,項目名稱:genera,代碼行數:9,代碼來源:EntityFaerie.java

示例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 );
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:11,代碼來源:MessageS4CEntityTeleport.java

示例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);
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:13,代碼來源:DefaultRowUpdaterTest.java


注:本文中的io.netty.buffer.ByteBuf.writeDouble方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。