io.vertx.core.buffer.Buffer.setFloat()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中io.vertx.core.buffer.Buffer.setFloat()方法的一些代码示例,展示了Buffer.setFloat()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Buffer.setFloat()方法的具体详情如下:
包路径:io.vertx.core.buffer.Buffer
类名称:Buffer
方法名:setFloat

Buffer.setFloat介绍

[英]Sets the float at position pos in the Buffer to the value f.

The buffer will expand as necessary to accommodate any value written.
[中]将缓冲区中位置pos处的浮点设置为值f。
缓冲区将根据需要扩展以容纳任何写入的值。

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

private void testSetFloat(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  buff.setFloat(i * 4, (float) i);
 }
 for (int i = 0; i < numSets; i++) {
  assertEquals((float) i, buff.getFloat(i * 4), 0);
 }
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testGetFloat() throws Exception {
 int numFloats = 100;
 Buffer b = Buffer.buffer(numFloats * 4);
 for (int i = 0; i < numFloats; i++) {
  b.setFloat(i * 4, i);
 }
 for (int i = 0; i < numFloats; i++) {
  assertEquals((float) i, b.getFloat(i * 4), 0);
 }
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testSetOutOfBounds() throws Exception {
 Buffer b = Buffer.buffer(numSets);
 assertIndexOutOfBoundsException(() -> b.setByte(-1, (byte) 0));
 assertIndexOutOfBoundsException(() -> b.setInt(-1, 0));
 assertIndexOutOfBoundsException(() -> b.setLong(-1, 0));
 assertIndexOutOfBoundsException(() -> b.setDouble(-1, 0));
 assertIndexOutOfBoundsException(() -> b.setFloat(-1, 0));
 assertIndexOutOfBoundsException(() -> b.setShort(-1, (short) 0));
 assertIndexOutOfBoundsException(() -> b.setBuffer(-1, b));
 assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, -1, 0));
 assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, 0, -1));
 assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1)));
 assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), -1, 0));
 assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), 0, -1));
 assertIndexOutOfBoundsException(() -> b.setString(-1, ""));
 assertIndexOutOfBoundsException(() -> b.setString(-1, "", "UTF-8"));
}

代码示例来源:origin: io.vertx/vertx-core

private void testSetFloat(Buffer buff) throws Exception {
 for (int i = 0; i < numSets; i++) {
  buff.setFloat(i * 4, (float) i);
 }
 for (int i = 0; i < numSets; i++) {
  assertEquals((float) i, buff.getFloat(i * 4), 0);
 }
}

代码示例来源:origin: io.vertx/vertx-core

@Test
public void testGetFloat() throws Exception {
 int numFloats = 100;
 Buffer b = Buffer.buffer(numFloats * 4);
 for (int i = 0; i < numFloats; i++) {
  b.setFloat(i * 4, i);
 }
 for (int i = 0; i < numFloats; i++) {
  assertEquals((float) i, b.getFloat(i * 4), 0);
 }
}

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Sets the <code>float</code> at position <code>pos</code> in the Buffer to the value <code>f</code>.<p>
 * The buffer will expand as necessary to accommodate any value written.
 * @param pos 
 * @param f 
 * @return 
 */
public io.vertx.rxjava.core.buffer.Buffer setFloat(int pos, float f) { 
 delegate.setFloat(pos, f);
 return this;
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * Sets the <code>float</code> at position <code>pos</code> in the Buffer to the value <code>f</code>.<p>
 * The buffer will expand as necessary to accommodate any value written.
 * @param pos 
 * @param f 
 * @return 
 */
public io.vertx.rxjava.core.buffer.Buffer setFloat(int pos, float f) { 
 delegate.setFloat(pos, f);
 return this;
}

代码示例来源:origin: io.vertx/vertx-core

@Test
public void testSetOutOfBounds() throws Exception {
 Buffer b = Buffer.buffer(numSets);
 assertIndexOutOfBoundsException(() -> b.setByte(-1, (byte) 0));
 assertIndexOutOfBoundsException(() -> b.setInt(-1, 0));
 assertIndexOutOfBoundsException(() -> b.setLong(-1, 0));
 assertIndexOutOfBoundsException(() -> b.setDouble(-1, 0));
 assertIndexOutOfBoundsException(() -> b.setFloat(-1, 0));
 assertIndexOutOfBoundsException(() -> b.setShort(-1, (short) 0));
 assertIndexOutOfBoundsException(() -> b.setBuffer(-1, b));
 assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, -1, 0));
 assertIndexOutOfBoundsException(() -> b.setBuffer(0, b, 0, -1));
 assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1)));
 assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), -1, 0));
 assertIndexOutOfBoundsException(() -> b.setBytes(-1, TestUtils.randomByteArray(1), 0, -1));
 assertIndexOutOfBoundsException(() -> b.setString(-1, ""));
 assertIndexOutOfBoundsException(() -> b.setString(-1, "", "UTF-8"));
}

代码示例来源:origin: com.jukusoft/vertx-binary-serializer

buf.setFloat(_pos, floatValue);
  _pos += 4;
} else if (clazz == SDouble.class) {

相关文章