当前位置: 首页>>代码示例>>Java>>正文


Java ByteBuffer.hashCode方法代码示例

本文整理汇总了Java中java.nio.ByteBuffer.hashCode方法的典型用法代码示例。如果您正苦于以下问题:Java ByteBuffer.hashCode方法的具体用法?Java ByteBuffer.hashCode怎么用?Java ByteBuffer.hashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.hashCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toHex

import java.nio.ByteBuffer; //导入方法依赖的package包/类
/**
 * Returns a formatted hex string of an area of this Memory.
 * Used primarily for testing.
 * @param preamble a descriptive header
 * @param offsetBytes offset bytes relative to the Memory start
 * @param lengthBytes number of bytes to convert to a hex string
 * @param state the ResourceState
 * @return a formatted hex string in a human readable array
 */
static String toHex(final String preamble, final long offsetBytes, final int lengthBytes,
    final ResourceState state) {
  checkBounds(offsetBytes, lengthBytes, state.getCapacity());
  final StringBuilder sb = new StringBuilder();
  final Object uObj = state.getUnsafeObject();
  final String uObjStr = (uObj == null) ? "null"
          : uObj.getClass().getSimpleName() + ", " + (uObj.hashCode() & 0XFFFFFFFFL);
  final ByteBuffer bb = state.getByteBuffer();
  final String bbStr = (bb == null) ? "null"
          : bb.getClass().getSimpleName() + ", " + (bb.hashCode() & 0XFFFFFFFFL);
  final MemoryRequestServer memReqSvr = state.getMemoryRequestServer();
  final String memReqStr = (memReqSvr == null) ? "null"
          : memReqSvr.getClass().getSimpleName() + ", " + (memReqSvr.hashCode() & 0XFFFFFFFFL);
  final long cumBaseOffset = state.getCumBaseOffset();
  sb.append(preamble).append(LS);
  sb.append("NativeBaseOffset    : ").append(state.getNativeBaseOffset()).append(LS);
  sb.append("UnsafeObj, hashCode : ").append(uObjStr).append(LS);
  sb.append("UnsafeObjHeader     : ").append(state.getUnsafeObjectHeader()).append(LS);
  sb.append("ByteBuf, hashCode   : ").append(bbStr).append(LS);
  sb.append("RegionOffset        : ").append(state.getRegionOffset()).append(LS);
  sb.append("Capacity            : ").append(state.getCapacity()).append(LS);
  sb.append("CumBaseOffset       : ").append(cumBaseOffset).append(LS);
  sb.append("MemReq, hashCode    : ").append(memReqStr).append(LS);
  sb.append("Valid               : ").append(state.isValid()).append(LS);
  sb.append("Resource Read Only  : ").append(state.isResourceReadOnly()).append(LS);
  sb.append("Resource Endianness : ").append(state.order().toString()).append(LS);
  sb.append("JDK Version         : ").append(UnsafeUtil.JDK).append(LS);
  //Data detail
  sb.append("Data, littleEndian  :  0  1  2  3  4  5  6  7");

  for (long i = 0; i < lengthBytes; i++) {
    final int b = unsafe.getByte(uObj, cumBaseOffset + offsetBytes + i) & 0XFF;
    if ((i % 8) == 0) { //row header
      sb.append(String.format("%n%20s: ", offsetBytes + i));
    }
    sb.append(String.format("%02x ", b));
  }
  sb.append(LS);

  return sb.toString();
}
 
开发者ID:DataSketches,项目名称:memory,代码行数:51,代码来源:Memory.java


注:本文中的java.nio.ByteBuffer.hashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。