Android ShortBuffer Create makeShortBuffer(int size)

Here you can find the source of makeShortBuffer(int size)

Description

make Short Buffer

Declaration

public static ShortBuffer makeShortBuffer(int size) 

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);/*w  ww .j  av a2  s  . co  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)
  2. createShortIndicesBuffer( final int capacity, final ShortBuffer previous)
  3. newShortBuffer(int numShorts)
  4. newShortBuffer(int numShorts)
  5. newShortBuffer(int paramInt)
  6. makeShortBuffer(short[] arr)
  7. createDirectShortBuffer( final int capacity)
  8. createDirectShortBuffer( final int capacity, final ShortBuffer previous)
  9. buildShortBuffer(short[] buffer)