Java IntBuffer Create createIntBuffer(int size)

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

Description

Construct a direct native-order intbuffer with the specified number of elements.

License

Open Source License

Parameter

Parameter Description
size The size, in ints

Return

an IntBuffer

Declaration

public static IntBuffer createIntBuffer(int size) 

Method Source Code


//package com.java2s;

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

import java.nio.IntBuffer;

public class Main {
    /**/*w  ww. j ava2s  . co  m*/
     * Construct a direct native-order intbuffer with the specified number
     * of elements.
     * @param size The size, in ints
     * @return an IntBuffer
     */
    public static IntBuffer createIntBuffer(int size) {
        return createByteBuffer(size << 2).asIntBuffer();
    }

    /**
     * Construct a direct native-ordered bytebuffer with the specified size.
     * @param size The size, in bytes
     * @return a ByteBuffer
     */
    public static ByteBuffer createByteBuffer(int size) {
        return ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
    }
}

Related

  1. createIntBuffer(final int... data)
  2. createIntBuffer(final int... data)
  3. createIntBuffer(int capacity)
  4. createIntBuffer(int size)
  5. createIntBuffer(int size)
  6. createIntBuffer(int... data)
  7. createIntBuffer(int[] array)
  8. createIntBufferOnHeap(final int size)