Android ShortBuffer Create asShortBuffer(short[] array)

Here you can find the source of asShortBuffer(short[] array)

Description

as Short Buffer

Declaration

public static ShortBuffer asShortBuffer(short[] array) 

Method Source Code

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

import java.nio.ShortBuffer;

public class Main {
    public static final int BYTES_PER_SHORT = Short.SIZE / Byte.SIZE;

    public static ShortBuffer asShortBuffer(short[] array) {
        ByteBuffer bbuf = ByteBuffer.allocateDirect(array.length
                * BYTES_PER_SHORT);/*ww w .  jav  a  2s  .  co m*/
        bbuf.order(ByteOrder.nativeOrder());
        ShortBuffer sbuf = bbuf.asShortBuffer();
        sbuf.put(array);
        sbuf.position(0);
        return sbuf;
    }
}

Related

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