/** * Allocates a direct native-order intbuffer with the specified number * of elements. * * @param capacity The capacity, in ints * * @return an IntBuffer */ public static IntBuffer createIntBuffer(int capacity) { return createByteBuffer(getAllocationSize(capacity, 2)).asIntBuffer(); }
/** * Allocates a direct native-order doublebuffer with the specified number * of elements. * * @param capacity The capacity, in doubles * * @return a DoubleBuffer */ public static DoubleBuffer createDoubleBuffer(int capacity) { return createByteBuffer(getAllocationSize(capacity, 3)).asDoubleBuffer(); }
/** * Allocates a direct native-order shortbuffer with the specified number * of elements. * * @param capacity The capacity, in shorts * * @return a ShortBuffer */ public static ShortBuffer createShortBuffer(int capacity) { return createByteBuffer(getAllocationSize(capacity, 1)).asShortBuffer(); }
/** * Allocates a direct native-order longbuffer with the specified number * of elements. * * @param capacity The capacity, in longs * * @return an LongBuffer */ public static LongBuffer createLongBuffer(int capacity) { return createByteBuffer(getAllocationSize(capacity, 3)).asLongBuffer(); }
/** * Allocates a direct native-order floatbuffer with the specified number * of elements. * * @param capacity The capacity, in floats * * @return a FloatBuffer */ public static FloatBuffer createFloatBuffer(int capacity) { return createByteBuffer(getAllocationSize(capacity, 2)).asFloatBuffer(); }
/** * Allocates a direct native-order charbuffer with the specified number * of elements. * * @param capacity The capacity, in chars * * @return an CharBuffer */ public static CharBuffer createCharBuffer(int capacity) { return createByteBuffer(getAllocationSize(capacity, 1)).asCharBuffer(); }
/** * Allocates a new pointer buffer. * * <p>The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined.</p> * * @param capacity the new buffer's capacity, in pointers * * @return the new pointer buffer * * @throws IllegalArgumentException If the {@code capacity} is a negative integer */ public static PointerBuffer allocateDirect(int capacity) { ByteBuffer source = BufferUtils.createByteBuffer(BufferUtils.getAllocationSize(capacity, POINTER_SHIFT)); return wrap(PointerBuffer.class, memAddress(source), capacity, source); }