Example usage for java.nio FloatBuffer clear

List of usage examples for java.nio FloatBuffer clear

Introduction

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

Prototype

public final Buffer clear() 

Source Link

Document

Clears this buffer.

Usage

From source file:Main.java

public static FloatBuffer replaceFloats(FloatBuffer dest, float... src) {
    dest.clear();
    dest.put(src);// w w w . j a  v  a 2s . com
    dest.position(0);
    return dest;
}

From source file:Main.java

/**
 * Create a new float[] array and populate it with the given FloatBuffer's
 * contents./*from ww  w  . j  a va2 s .  com*/
 * 
 * @param buff
 *            the FloatBuffer to read from
 * @return a new float array populated from the FloatBuffer
 */
public static float[] getFloatArray(FloatBuffer buff) {
    if (buff == null) {
        return null;
    }
    buff.clear();
    float[] inds = new float[buff.limit()];
    for (int x = 0; x < inds.length; x++) {
        inds[x] = buff.get();
    }
    return inds;
}

From source file:Main.java

public static float[] getFloatArray(final FloatBuffer buff) {
    if (buff == null) {
        return null;
    }//from w w w.j a v  a2s .  c om
    buff.clear();
    final float[] inds = new float[buff.limit()];
    for (int x = 0; x < inds.length; x++) {
        inds[x] = buff.get();
    }
    return inds;
}

From source file:Main.java

public static FloatBuffer createFloatBufferOnHeap(final int size) {
    final FloatBuffer buf = ByteBuffer.allocate(4 * size).order(ByteOrder.nativeOrder()).asFloatBuffer();
    buf.clear();
    return buf;// w  w w.j  a va2  s  .  c  om
}

From source file:Main.java

public static FloatBuffer createFloatBuffer(FloatBuffer buffer) {
    FloatBuffer dest = createFloatBuffer(buffer.capacity());
    dest.clear();
    dest.put(buffer);/*w w  w . j a  v a  2 s .  com*/
    dest.position(0);
    return dest;
}

From source file:Main.java

public static FloatBuffer createFloatBuffer(FloatBuffer buf) {
    FloatBuffer dest = createFloatBuffer(buf.capacity());
    dest.clear();
    dest.put(buf);//ww w  .  ja  v  a 2 s . co m
    dest.position(0);
    return dest;
}

From source file:Main.java

public static FloatBuffer createFloatBufferOnHeap(final int size) {
    final FloatBuffer buf = ByteBuffer.allocate(SIZEOF_FLOAT * size).order(ByteOrder.nativeOrder())
            .asFloatBuffer();//  www. j a va  2s . c o m
    buf.clear();
    return buf;
}

From source file:Main.java

public static FloatBuffer createFloatBuffer(final int size) {
    final FloatBuffer buf = ByteBuffer.allocateDirect(4 * size).order(ByteOrder.nativeOrder()).asFloatBuffer();
    buf.clear();
    return buf;/*from   ww  w  .j ava  2  s .  c  o m*/
}

From source file:Main.java

public static FloatBuffer createFloatBuffer(final int size) {
    final FloatBuffer buf = ByteBuffer.allocateDirect(SIZEOF_FLOAT * size).order(ByteOrder.nativeOrder())
            .asFloatBuffer();/*from ww  w . j a  v  a2s.  c  o  m*/
    buf.clear();
    return buf;
}

From source file:Main.java

public static FloatBuffer setupFloatBuffer(FloatBuffer preBuffer, float[] array) {

    if (preBuffer == null || preBuffer.capacity() < array.length) {
        preBuffer = createFloatBuffer(array.length * 2);
    } else {//from  w w w. jav a2 s . co m
        preBuffer.clear();
    }
    preBuffer.put(array);
    preBuffer.position(0);
    return preBuffer;
}