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

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

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

Buffer.setMediumLE介绍

[英]Sets the 24bit int at position pos in the Buffer to the value i. in the Little Endian Byte Order

The buffer will expand as necessary to accommodate any value written.
[中]将缓冲区中位置pos处的24位int设置为值i。按小尾端字节顺序
缓冲区将根据需要扩展以容纳任何写入的值。

代码示例

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

private void testGetSetMedium(boolean isLE) throws Exception {
 int numInts = 100;
 Buffer b = Buffer.buffer(numInts * 3);
 for (int i = 0; i < numInts; i++) {
  if (isLE) {
   b.setMediumLE(i * 3, MEDIUM_MAX_VALUE + i);
  } else {
   b.setMedium(i * 3, MEDIUM_MAX_VALUE + i);
  }
 }
 for (int i = 0; i < numInts; i++) {
  if (isLE) {
   assertEquals((MEDIUM_MAX_VALUE + i - MEDIUM_MAX_VALUE), b.getMediumLE(i * 3));
  } else {
   assertEquals((MEDIUM_MAX_VALUE + i - MEDIUM_MAX_VALUE), b.getMedium(i * 3));
  }
 }
}

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

private void testGetSetUnsignedMedium(boolean isLE) throws Exception {
 int numInts = 100;
 int MEDIUM_MAX_VALUE = BufferTest.MEDIUM_MAX_VALUE - numInts;
 Buffer b = Buffer.buffer(numInts * 3);
 for (int i = 0; i < numInts; i++) {
  if (isLE) {
   b.setMediumLE(i * 3, (MEDIUM_MAX_VALUE + i));
  } else {
   b.setMedium(i * 3, (MEDIUM_MAX_VALUE + i));
  }
 }
 for (int i = 0; i < numInts; i++) {
  if (isLE) {
   assertEquals(Integer.toUnsignedLong(MEDIUM_MAX_VALUE + i), b.getUnsignedMediumLE(i * 3));
  } else {
   assertEquals(Integer.toUnsignedLong(MEDIUM_MAX_VALUE + i), b.getUnsignedMedium(i * 3));
  }
 }
}

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

/**
 * Sets the 24bit <code>int</code> at position <code>pos</code> in the Buffer to the value <code>i</code>. in the Little Endian Byte Order<p>
 * The buffer will expand as necessary to accommodate any value written.
 * @param pos 
 * @param i 
 * @return 
 */
public io.vertx.rxjava.core.buffer.Buffer setMediumLE(int pos, int i) { 
 delegate.setMediumLE(pos, i);
 return this;
}

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

/**
 * Sets the 24bit <code>int</code> at position <code>pos</code> in the Buffer to the value <code>i</code>. in the Little Endian Byte Order<p>
 * The buffer will expand as necessary to accommodate any value written.
 * @param pos 
 * @param i 
 * @return 
 */
public io.vertx.rxjava.core.buffer.Buffer setMediumLE(int pos, int i) { 
 delegate.setMediumLE(pos, i);
 return this;
}

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

private void testGetSetMedium(boolean isLE) throws Exception {
 int numInts = 100;
 Buffer b = Buffer.buffer(numInts * 3);
 for (int i = 0; i < numInts; i++) {
  if (isLE) {
   b.setMediumLE(i * 3, MEDIUM_MAX_VALUE + i);
  } else {
   b.setMedium(i * 3, MEDIUM_MAX_VALUE + i);
  }
 }
 for (int i = 0; i < numInts; i++) {
  if (isLE) {
   assertEquals((MEDIUM_MAX_VALUE + i - MEDIUM_MAX_VALUE), b.getMediumLE(i * 3));
  } else {
   assertEquals((MEDIUM_MAX_VALUE + i - MEDIUM_MAX_VALUE), b.getMedium(i * 3));
  }
 }
}

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

private void testGetSetUnsignedMedium(boolean isLE) throws Exception {
 int numInts = 100;
 int MEDIUM_MAX_VALUE = BufferTest.MEDIUM_MAX_VALUE - numInts;
 Buffer b = Buffer.buffer(numInts * 3);
 for (int i = 0; i < numInts; i++) {
  if (isLE) {
   b.setMediumLE(i * 3, (MEDIUM_MAX_VALUE + i));
  } else {
   b.setMedium(i * 3, (MEDIUM_MAX_VALUE + i));
  }
 }
 for (int i = 0; i < numInts; i++) {
  if (isLE) {
   assertEquals(Integer.toUnsignedLong(MEDIUM_MAX_VALUE + i), b.getUnsignedMediumLE(i * 3));
  } else {
   assertEquals(Integer.toUnsignedLong(MEDIUM_MAX_VALUE + i), b.getUnsignedMedium(i * 3));
  }
 }
}

相关文章