Android ShortBuffer Create buildShortBuffer(short[] buffer)

Here you can find the source of buildShortBuffer(short[] buffer)

Description

build ShortBuffer: short[] -> ShortBuffer

Parameter

Parameter Description
buffer a parameter

Return

ShortBuffer

Declaration

public static ShortBuffer buildShortBuffer(short[] buffer) 

Method Source Code

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

import java.nio.ShortBuffer;

public class Main {
    /**/*from w w  w.ja v a2  s.  co  m*/
     * build ShortBuffer: short[] -> ShortBuffer
     * 
     * @param buffer
     * @return ShortBuffer
     */
    public static ShortBuffer buildShortBuffer(short[] buffer) {
        ShortBuffer ret = null;

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

        return ret;
    }
}

Related

  1. newShortBuffer(int paramInt)
  2. makeShortBuffer(int size)
  3. makeShortBuffer(short[] arr)
  4. createDirectShortBuffer( final int capacity)
  5. createDirectShortBuffer( final int capacity, final ShortBuffer previous)
  6. asShortBuffer(short[] array)
  7. getShortBuffer(short[] list)
  8. toShortBuffer(short[] array)
  9. shotToBuffer(short[] a)