Java ByteBuffer Allocate allocateInts(final int[] intarray, final int SIZE)

Here you can find the source of allocateInts(final int[] intarray, final int SIZE)

Description

allocate Ints

License

Open Source License

Declaration

public static IntBuffer allocateInts(final int[] intarray, final int SIZE) 

Method Source Code

//package com.java2s;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

import java.nio.IntBuffer;

public class Main {
    public static IntBuffer allocateInts(final int howmany, final int SIZE) {
        return ByteBuffer.allocateDirect(howmany * SIZE).order(ByteOrder.nativeOrder()).asIntBuffer();
    }//from  ww w .  j  a  v  a2s  .  co  m

    public static IntBuffer allocateInts(final int[] intarray, final int SIZE) {
        IntBuffer ib = ByteBuffer.allocateDirect(intarray.length * SIZE).order(ByteOrder.nativeOrder())
                .asIntBuffer();
        ib.put(intarray).flip();
        return ib;
    }
}

Related

  1. allocateDirectBuffer(int size)
  2. allocateDirectInt(int size)
  3. allocateDoubles(final int howmany, final int SIZE)
  4. allocateFloats(final int howmany, final int SIZE)
  5. allocateInt()
  6. allocateNativeOrderDirectBuffer(int size)
  7. allocateTestBuffer(int capacity, boolean direct)
  8. fromBytes(byte[] data, boolean[] preAllocatedValues)