Example usage for java.nio ShortBuffer clear

List of usage examples for java.nio ShortBuffer clear

Introduction

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

Prototype

public final Buffer clear() 

Source Link

Document

Clears this buffer.

Usage

From source file:Main.java

public static ShortBuffer createShortBuffer(final short... data) {
    if (data == null) {
        return null;
    }//from  w  ww .j  a va 2  s  .c om
    final ShortBuffer buff = createShortBuffer(data.length);
    buff.clear();
    buff.put(data);
    buff.flip();
    return buff;
}

From source file:Main.java

public static ShortBuffer createShortBufferOnHeap(final int size) {
    final ShortBuffer buf = ByteBuffer.allocate(2 * size).order(ByteOrder.nativeOrder()).asShortBuffer();
    buf.clear();
    return buf;//from  ww w  .j  a  va 2s .co m
}

From source file:Main.java

public static ShortBuffer createShortBuffer(final int size) {
    final ShortBuffer buf = ByteBuffer.allocateDirect(2 * size).order(ByteOrder.nativeOrder()).asShortBuffer();
    buf.clear();
    return buf;/*from   ww w. ja  va2s . c  o  m*/
}

From source file:Main.java

public static ShortBuffer createShortBuffer(final int size) {
    final ShortBuffer buf = ByteBuffer.allocateDirect(SIZEOF_SHORT * size).order(ByteOrder.nativeOrder())
            .asShortBuffer();//from  ww w  .j  a v a2  s. co  m
    buf.clear();
    return buf;
}

From source file:Main.java

public static ShortBuffer setupShortBuffer(ShortBuffer preBuffer, short[] array) {

    if (preBuffer == null || preBuffer.capacity() < array.length) {
        preBuffer = createShortBuffer(array.length * 2);
    } else {//from w  ww .  jav  a 2  s  . c o m
        preBuffer.clear();
    }

    preBuffer.clear();
    preBuffer.put(array);
    preBuffer.position(0);

    return preBuffer;
}

From source file:Main.java

public static ShortBuffer createShortBufferOnHeap(final int size) {
    final ShortBuffer buf = ByteBuffer.allocate(SIZEOF_SHORT * size).order(ByteOrder.nativeOrder())
            .asShortBuffer();/*from  ww  w.  jav a  2  s. c  o m*/
    buf.clear();
    return buf;
}