Java Code Examples for com.google.common.primitives.Floats#BYTES

The following examples show how to use com.google.common.primitives.Floats#BYTES . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImmutableNode.java    From bytebuffer-collections with Apache License 2.0 6 votes vote down vote up
public ImmutableNode(
    int numDims,
    int initialOffset,
    int offsetFromInitial,
    ByteBuffer data,
    BitmapFactory bitmapFactory
)
{
  this.bitmapFactory = bitmapFactory;
  this.numDims = numDims;
  this.initialOffset = initialOffset;
  this.offsetFromInitial = offsetFromInitial;
  short header = data.getShort(initialOffset + offsetFromInitial);
  this.isLeaf = (header & 0x8000) != 0;
  this.numChildren = (short) (header & 0x7FFF);
  final int sizePosition = initialOffset + offsetFromInitial + HEADER_NUM_BYTES + 2 * numDims * Floats.BYTES;
  int bitmapSize = data.getInt(sizePosition);
  this.childrenOffset = initialOffset
                        + offsetFromInitial
                        + HEADER_NUM_BYTES
                        + 2 * numDims * Floats.BYTES
                        + Ints.BYTES
                        + bitmapSize;

  this.data = data;
}
 
Example 2
Source File: Node.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
public int getSizeInBytes()
{
  return ImmutableNode.HEADER_NUM_BYTES
         + 2 * getNumDims() * Floats.BYTES
         + Ints.BYTES // size of the set
         + bitmap.getSizeInBytes()
         + getChildren().size() * Ints.BYTES;
}
 
Example 3
Source File: ImmutableNode.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
public ImmutableNode(
    int numDims,
    int initialOffset,
    int offsetFromInitial,
    short numChildren,
    boolean leaf,
    ByteBuffer data,
    BitmapFactory bitmapFactory
)
{
  this.bitmapFactory = bitmapFactory;
  this.numDims = numDims;
  this.initialOffset = initialOffset;
  this.offsetFromInitial = offsetFromInitial;
  this.numChildren = numChildren;
  this.isLeaf = leaf;
  final int sizePosition = initialOffset + offsetFromInitial + HEADER_NUM_BYTES + 2 * numDims * Floats.BYTES;
  int bitmapSize = data.getInt(sizePosition);
  this.childrenOffset = initialOffset
                        + offsetFromInitial
                        + HEADER_NUM_BYTES
                        + 2 * numDims * Floats.BYTES
                        + Ints.BYTES
                        + bitmapSize;

  this.data = data;
}
 
Example 4
Source File: ImmutableNode.java    From bytebuffer-collections with Apache License 2.0 5 votes vote down vote up
public ImmutableBitmap getImmutableBitmap()
{
  final int sizePosition = initialOffset + offsetFromInitial + HEADER_NUM_BYTES + 2 * numDims * Floats.BYTES;
  int numBytes = data.getInt(sizePosition);
  data.position(sizePosition + Ints.BYTES);
  ByteBuffer tmpBuffer = data.slice();
  tmpBuffer.limit(numBytes);
  return bitmapFactory.mapImmutableBitmap(tmpBuffer.asReadOnlyBuffer());
}