Android FloatBuffer Create buildFloatBuffer(float[] buffer)

Here you can find the source of buildFloatBuffer(float[] buffer)

Description

build FloatBuffer: float[] -> FloatBuffer

Parameter

Parameter Description
buffer a parameter

Return

FloatBuffer

Declaration

public static FloatBuffer buildFloatBuffer(float[] buffer) 

Method Source Code

//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;

public class Main {
    /**//ww  w.  ja  va  2 s  .c  o m
     * build FloatBuffer: float[] -> FloatBuffer
     * 
     * @param buffer
     * @return FloatBuffer
     */
    public static FloatBuffer buildFloatBuffer(float[] buffer) {
        FloatBuffer ret = null;

        if (buffer != null) {
            ByteBuffer byteBuffer = ByteBuffer
                    .allocateDirect(buffer.length * 4);
            byteBuffer.order(ByteOrder.nativeOrder());
            ret = byteBuffer.asFloatBuffer();
            ret.put(buffer);
            ret.position(0);
        }

        return ret;
    }
}

Related

  1. floatToBuffer(float[] a)
  2. setupFloatBuffer(FloatBuffer preBuffer, float[] array)
  3. list2FloatBuffer(List arr)
  4. list2FloatBuffer(List list)
  5. getFloatBuffer(float[] list)
  6. asFloatBuffer(float[] array)
  7. wrap(float[] buffer)
  8. makeFloatBuffer(float[] array)
  9. makeFloatBuffer(float[][] array, int rows, int cols)