Android IntBuffer Create buildIntBuffer(int[] buffer)

Here you can find the source of buildIntBuffer(int[] buffer)

Description

build IntBuffer: int[] -> IntBuffer

Parameter

Parameter Description
buffer a parameter

Return

IntBuffer

Declaration

public static IntBuffer buildIntBuffer(int[] buffer) 

Method Source Code

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

import java.nio.IntBuffer;

public class Main {
    /**/*from ww w  . ja  v  a2  s  .  c  om*/
     * build IntBuffer: int[] -> IntBuffer
     * 
     * @param buffer
     * @return IntBuffer
     */
    public static IntBuffer buildIntBuffer(int[] buffer) {
        IntBuffer ret = null;

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

        return ret;
    }
}

Related

  1. newIntBuffer(int paramInt)
  2. setupIntBuffer(IntBuffer preBuffer, int[] array)
  3. toIntBuffer(int[] array)
  4. createDirectIntBuffer(final int capacity)
  5. createDirectIntBuffer(final int capacity, final IntBuffer previous)
  6. makeIntBuffer(int[] array)