Example usage for java.nio ByteBuffer asIntBuffer

List of usage examples for java.nio ByteBuffer asIntBuffer

Introduction

In this page you can find the example usage for java.nio ByteBuffer asIntBuffer.

Prototype

public abstract IntBuffer asIntBuffer();

Source Link

Document

Returns a int buffer which is based on the remaining content of this byte buffer.

Usage

From source file:Main.java

private static IntBuffer newIntBuffer(int size) {
    ByteBuffer buffer = ByteBuffer.allocateDirect(size);
    buffer.order(ByteOrder.LITTLE_ENDIAN);
    return buffer.asIntBuffer();
}

From source file:Main.java

public static IntBuffer newIntBuffer(int numInts) {
    ByteBuffer buffer = ByteBuffer.allocate(numInts * 4);
    buffer.order(ByteOrder.nativeOrder());
    return buffer.asIntBuffer();
}

From source file:Main.java

public static IntBuffer allocateInttBuffer(int capacity) {
    ByteBuffer vbb = ByteBuffer.allocateDirect(capacity);
    vbb.order(ByteOrder.nativeOrder());
    return vbb.asIntBuffer();
}

From source file:Main.java

public static IntBuffer allocateInttBuffer(int capacity) {
    final ByteBuffer vbb = ByteBuffer.allocateDirect(capacity);
    vbb.order(ByteOrder.nativeOrder());
    return vbb.asIntBuffer();
}

From source file:Main.java

public static IntBuffer newIntBuffer(int numInts) {
    ByteBuffer buffer = ByteBuffer.allocateDirect(numInts * 4);
    buffer.order(ByteOrder.nativeOrder());
    return buffer.asIntBuffer();
}

From source file:Main.java

public static IntBuffer createIndexBuffer(int[] indices) {
    IntBuffer indexBuffer;/*from   w  w w .j ava 2 s  .  co  m*/

    ByteBuffer bb = ByteBuffer.allocateDirect(indices.length * 4);
    bb.order(ByteOrder.nativeOrder());
    indexBuffer = bb.asIntBuffer();
    indexBuffer.put(indices);
    indexBuffer.position(0);

    return indexBuffer;
}

From source file:Main.java

public static IntBuffer getIntBuffer(int[] coords) {
    ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 4);
    bb.order(ByteOrder.nativeOrder());
    IntBuffer intBuffer = bb.asIntBuffer();
    intBuffer.put(coords);/*from  w w w. j av a 2  s  .com*/
    intBuffer.position(0);
    return intBuffer;
}

From source file:Main.java

public static IntBuffer createIntBuffer(int count) {
    ByteBuffer data = ByteBuffer.allocateDirect(count * 4);
    data.order(ByteOrder.nativeOrder());
    IntBuffer p1 = data.asIntBuffer();
    return p1;//from w w w.  j a va  2 s .c  o m
}

From source file:Main.java

public static IntBuffer makeBuffer(int[] data) {
    ByteBuffer b = ByteBuffer.allocateDirect(data.length * 4);
    b.order(ByteOrder.nativeOrder());
    IntBuffer buffer = b.asIntBuffer();
    buffer.put(data);//from  w ww  .jav  a 2  s.  c o  m
    buffer.position(0);
    return buffer;
}

From source file:Main.java

public static IntBuffer intArrayToBuffer(int[] intArray) {
    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(intArray.length * 4);
    byteBuffer.order(ByteOrder.nativeOrder());
    IntBuffer intBuffer = byteBuffer.asIntBuffer();
    intBuffer.put(intArray);/*w  w  w  .jav  a  2  s .  c om*/
    intBuffer.position(0);
    return intBuffer;
}