Example usage for java.nio ShortBuffer position

List of usage examples for java.nio ShortBuffer position

Introduction

In this page you can find the example usage for java.nio ShortBuffer position.

Prototype

public final Buffer position(int newPosition) 

Source Link

Document

Sets the position of this buffer.

Usage

From source file:Main.java

public static ShortBuffer toShortBuffer(short[] v) {
    ByteBuffer buff = ByteBuffer.allocateDirect(v.length * 2);
    buff.order(ByteOrder.nativeOrder());
    ShortBuffer buffer = buff.asShortBuffer();
    buffer.put(v);// ww w  . j a  v  a2  s  . c o m
    buffer.position(0);
    return buffer;
}

From source file:Main.java

/**
 * /*from   w w w  .  ja  v  a  2 s.com*/
 * @since 1.0.0
 * @param v
 * @return the ShortBuffer
 */
public static ShortBuffer toShortBuffer(short[] v) {
    ByteBuffer buf = ByteBuffer.allocateDirect(v.length * 2);
    buf.order(ByteOrder.nativeOrder());
    ShortBuffer buffer = buf.asShortBuffer();
    buffer.put(v);
    buffer.position(0);
    return buffer;
}

From source file:Main.java

public static ShortBuffer buildShortBuffer(short[] array) {
    ByteBuffer byteBuf = ByteBuffer.allocateDirect(array.length * 2);
    byteBuf.order(ByteOrder.nativeOrder());
    ShortBuffer buffer = byteBuf.asShortBuffer();
    buffer.put(array);// w  w  w . jav  a2s.com
    buffer.position(0);
    return buffer;
}

From source file:Main.java

public static ShortBuffer create(short[] data) {
    ShortBuffer sb = create(data.length * 2).asShortBuffer().put(data);
    sb.position(0);
    return sb;//from  w w w . j a  va2  s .c om
}

From source file:Main.java

public static ShortBuffer getShortBuffer(short[] coords) {
    ByteBuffer bb = ByteBuffer.allocateDirect(coords.length * 2);
    bb.order(ByteOrder.nativeOrder());
    ShortBuffer shortBuffer = bb.asShortBuffer();
    shortBuffer.put(coords);/* ww  w.  j  a  va 2  s.com*/
    shortBuffer.position(0);
    return shortBuffer;
}

From source file:Main.java

public static ShortBuffer toShortBuffer(short[] values) {
    ByteBuffer vbb = ByteBuffer.allocateDirect(values.length * 2);
    vbb.order(ByteOrder.nativeOrder());
    ShortBuffer buffer = vbb.asShortBuffer();
    buffer.put(values);/*from  w  w w .jav  a 2  s  .co m*/
    buffer.position(0);
    return buffer;
}

From source file:Main.java

public static ShortBuffer toShortBuffer(short[] values) {
    final ByteBuffer vbb = ByteBuffer.allocateDirect(values.length * 2);
    vbb.order(ByteOrder.nativeOrder());
    final ShortBuffer buffer = vbb.asShortBuffer();
    buffer.put(values);/*from  w w  w.jav  a2 s .  c  om*/
    buffer.position(0);
    return buffer;
}

From source file:Main.java

public static ShortBuffer makeShortBuffer(short[] array) {
    if (array == null)
        throw new IllegalArgumentException();

    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(2 * array.length);
    byteBuffer.order(ByteOrder.nativeOrder());
    ShortBuffer shortBuffer = byteBuffer.asShortBuffer();
    shortBuffer.put(array);// w w w . j  a  v a 2  s .c o  m
    shortBuffer.position(0);
    return shortBuffer;
}

From source file:Main.java

/**
 * Creates a {@link ShortBuffer} based on the given data.
 *
 * @param data the data for the buffer/*from   w  w  w .ja  v  a2s  .  c  o  m*/
 * @return the short buffer
 */
public static ShortBuffer createShortBuffer(final short[] data) {
    if (data == null) {
        return null;
    }
    ByteBuffer bbVertices = ByteBuffer.allocateDirect(data.length * 4);
    bbVertices.order(ByteOrder.nativeOrder());
    final ShortBuffer fBuffer = bbVertices.asShortBuffer();
    fBuffer.put(data);
    fBuffer.position(0);
    return fBuffer;
}

From source file:Main.java

public static ShortBuffer shortToBuffer(short[] a) {
    ShortBuffer shortBuffer;
    ByteBuffer ibb = ByteBuffer.allocateDirect(a.length * 2);
    ibb.order(ByteOrder.nativeOrder());
    shortBuffer = ibb.asShortBuffer();/*from   w  w w . j  ava2 s  .  c om*/
    shortBuffer.put(a);
    shortBuffer.position(0);
    return shortBuffer;
}