Exemplo n.º 1
0
        /**
         * Allocates a new direct {@link java.nio.FloatBuffer} of the specified size, in chars.
         *
         * @param size           the new FloatBuffer's size.
         * @param allocateDirect true to allocate and return a direct buffer, false to allocate and return a non-direct
         *                       buffer.
         *
         * @return the new buffer.
         *
         * @throws ArgumentException if size is negative.
         */
        public static FloatBuffer newFloatBuffer(int size, bool allocateDirect)
        {
            if (size < 0)
            {
                String message = Logging.getMessage("generic.SizeOutOfRange", size);
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            return(allocateDirect ? newDirectByteBuffer(SIZEOF_FLOAT * size).asFloatBuffer() : FloatBuffer.allocate(size));
        }