Android ShortBuffer Create makeShortBuffer(short[] arr)

Here you can find the source of makeShortBuffer(short[] arr)

Description

make Short Buffer

Declaration

public static ShortBuffer makeShortBuffer(short[] arr) 

Method Source Code

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

import java.nio.ShortBuffer;

public class Main {
    public static ShortBuffer makeShortBuffer(short[] arr) {
        ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 2);
        bb.order(ByteOrder.nativeOrder());
        ShortBuffer Ib = bb.asShortBuffer();
        Ib.put(arr);/*from  w  ww. j  a  v  a 2  s . c o  m*/
        Ib.position(0);
        return Ib;
    }

    public static ShortBuffer makeShortBuffer(int size) {
        ByteBuffer bb = ByteBuffer.allocateDirect(size * 2);
        bb.order(ByteOrder.nativeOrder());
        ShortBuffer Ib = bb.asShortBuffer();
        Ib.position(0);
        return Ib;
    }
}

Related

  1. createShortIndicesBuffer( final int capacity, final ShortBuffer previous)
  2. newShortBuffer(int numShorts)
  3. newShortBuffer(int numShorts)
  4. newShortBuffer(int paramInt)
  5. makeShortBuffer(int size)
  6. createDirectShortBuffer( final int capacity)
  7. createDirectShortBuffer( final int capacity, final ShortBuffer previous)
  8. buildShortBuffer(short[] buffer)
  9. asShortBuffer(short[] array)