/* * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // -- This file was mechanically generated: Do not edit! -- // package java.nio; /** * A float buffer. * * <p> This class defines four categories of operations upon * float buffers: * * <ul> * * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and * {@link #put(float) </code><i>put</i><code>} methods that read and write * single floats; </p></li> * * <li><p> Relative {@link #get(float[]) </code><i>bulk get</i><code>} * methods that transfer contiguous sequences of floats from this buffer * into an array; and</p></li> * * <li><p> Relative {@link #put(float[]) </code><i>bulk put</i><code>} * methods that transfer contiguous sequences of floats from a * float array or some other float * buffer into this buffer; and </p></li> * * * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link * #duplicate </code>duplicating<code>}, and {@link #slice * </code>slicing<code>} a float buffer. </p></li> * * </ul> * * <p> Float buffers can be created either by {@link #allocate * </code><i>allocation</i><code>}, which allocates space for the buffer's * * * content, by {@link #wrap(float[]) </code><i>wrapping</i><code>} an existing * float array into a buffer, or by creating a * <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer. * * * * * <p> Like a byte buffer, a float buffer is either <a * href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A * float buffer created via the <tt>wrap</tt> methods of this class will * be non-direct. A float buffer created as a view of a byte buffer will * be direct if, and only if, the byte buffer itself is direct. Whether or not * a float buffer is direct may be determined by invoking the {@link * #isDirect isDirect} method. </p> * * * * * <p> Methods in this class that do not otherwise have a value to return are * specified to return the buffer upon which they are invoked. This allows * method invocations to be chained. * * * * @author Mark Reinhold * @author JSR-51 Expert Group * @since 1.4 */ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuffer>{ // These fields are declared here rather than in Heap-X-Buffer in order to // reduce the number of virtual method invocations needed to access these // values, which is especially costly when coding small buffers. // final float[] hb; // Non-null only for heap buffers final int offset; boolean isReadOnly; // Valid only for heap buffers // Creates a new buffer with the given mark, position, limit, capacity, // backing array, and array offset // FloatBuffer(int mark, int pos, int lim, int cap, // package-private float[] hb, int offset) { super(mark, pos, lim, cap); this.hb = hb; this.offset = offset; } // Creates a new buffer with the given mark, position, limit, and capacity // FloatBuffer(int mark, int pos, int lim, int cap) { // package-private this(mark, pos, lim, cap, null, 0); } /** * Allocates a new float buffer. * * <p> The new buffer's position will be zero, its limit will be its * capacity, its mark will be undefined, and each of its elements will be * initialized to zero. It will have a {@link #array * </code>backing array<code>}, and its {@link #arrayOffset </code>array * offset<code>} will be zero. * * @param capacity * The new buffer's capacity, in floats * * @return The new float buffer * * @throws IllegalArgumentException * If the <tt>capacity</tt> is a negative integer */ public static FloatBuffer allocate(int capacity) { if (capacity < 0) throw new IllegalArgumentException(); return new HeapFloatBuffer(capacity, capacity); } /** * Wraps a float array into a buffer. * * <p> The new buffer will be backed by the given float array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity will be * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit * will be <tt>offset + length</tt>, and its mark will be undefined. Its * {@link #array </code>backing array<code>} will be the given array, and * its {@link #arrayOffset </code>array offset<code>} will be zero. </p> * * @param array * The array that will back the new buffer * * @param offset * The offset of the subarray to be used; must be non-negative and * no larger than <tt>array.length</tt>. The new buffer's position * will be set to this value. * * @param length * The length of the subarray to be used; * must be non-negative and no larger than * <tt>array.length - offset</tt>. * The new buffer's limit will be set to <tt>offset + length</tt>. * * @return The new float buffer * * @throws IndexOutOfBoundsException * If the preconditions on the <tt>offset</tt> and <tt>length</tt> * parameters do not hold */ public static FloatBuffer wrap(float[] array, int offset, int length) { try { return new HeapFloatBuffer(array, offset, length); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } } /** * Wraps a float array into a buffer. * * <p> The new buffer will be backed by the given float array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity and limit will be * <tt>array.length</tt>, its position will be zero, and its mark will be * undefined. Its {@link #array </code>backing array<code>} will be the * given array, and its {@link #arrayOffset </code>array offset<code>} will * be zero. </p> * * @param array * The array that will back this buffer * * @return The new float buffer */ public static FloatBuffer wrap(float[] array) { return wrap(array, 0, array.length); } /** * Creates a new float buffer whose content is a shared subsequence of * this buffer's content. * * <p> The content of the new buffer will start at this buffer's current * position. Changes to this buffer's content will be visible in the new * buffer, and vice versa; the two buffers' position, limit, and mark * values will be independent. * * <p> The new buffer's position will be zero, its capacity and its limit * will be the number of floats remaining in this buffer, and its mark * will be undefined. The new buffer will be direct if, and only if, this * buffer is direct, and it will be read-only if, and only if, this bufferLines 1–500 of 1451. Load more
/* * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ // -- This file was mechanically generated: Do not edit! -- // package java.nio; /** * A float buffer. * * <p> This class defines four categories of operations upon * float buffers: * * <ul> * * <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and * {@link #put(float) </code><i>put</i><code>} methods that read and write * single floats; </p></li> * * <li><p> Relative {@link #get(float[]) </code><i>bulk get</i><code>} * methods that transfer contiguous sequences of floats from this buffer * into an array; and</p></li> * * <li><p> Relative {@link #put(float[]) </code><i>bulk put</i><code>} * methods that transfer contiguous sequences of floats from a * float array or some other float * buffer into this buffer; and </p></li> * * * <li><p> Methods for {@link #compact </code>compacting<code>}, {@link * #duplicate </code>duplicating<code>}, and {@link #slice * </code>slicing<code>} a float buffer. </p></li> * * </ul> * * <p> Float buffers can be created either by {@link #allocate * </code><i>allocation</i><code>}, which allocates space for the buffer's * * * content, by {@link #wrap(float[]) </code><i>wrapping</i><code>} an existing * float array into a buffer, or by creating a * <a href="ByteBuffer.html#views"><i>view</i></a> of an existing byte buffer. * * * * * <p> Like a byte buffer, a float buffer is either <a * href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>. A * float buffer created via the <tt>wrap</tt> methods of this class will * be non-direct. A float buffer created as a view of a byte buffer will * be direct if, and only if, the byte buffer itself is direct. Whether or not * a float buffer is direct may be determined by invoking the {@link * #isDirect isDirect} method. </p> * * * * * <p> Methods in this class that do not otherwise have a value to return are * specified to return the buffer upon which they are invoked. This allows * method invocations to be chained. * * * * @author Mark Reinhold * @author JSR-51 Expert Group * @since 1.4 */ public abstract class FloatBuffer extends Buffer implements Comparable<FloatBuffer> { // These fields are declared here rather than in Heap-X-Buffer in order to // reduce the number of virtual method invocations needed to access these // values, which is especially costly when coding small buffers. // final float[] hb; // Non-null only for heap buffers final int offset; boolean isReadOnly; // Valid only for heap buffers // Creates a new buffer with the given mark, position, limit, capacity, // backing array, and array offset // FloatBuffer(int mark, int pos, int lim, int cap, // package-private float[] hb, int offset) { super(mark, pos, lim, cap); this.hb = hb; this.offset = offset; } // Creates a new buffer with the given mark, position, limit, and capacity // FloatBuffer(int mark, int pos, int lim, int cap) { // package-private this(mark, pos, lim, cap, null, 0); } /** * Allocates a new float buffer. * * <p> The new buffer's position will be zero, its limit will be its * capacity, its mark will be undefined, and each of its elements will be * initialized to zero. It will have a {@link #array * </code>backing array<code>}, and its {@link #arrayOffset </code>array * offset<code>} will be zero. * * @param capacity * The new buffer's capacity, in floats * * @return The new float buffer * * @throws IllegalArgumentException * If the <tt>capacity</tt> is a negative integer */ public static FloatBuffer allocate(int capacity) { if (capacity < 0) throw new IllegalArgumentException(); return new HeapFloatBuffer(capacity, capacity); } /** * Wraps a float array into a buffer. * * <p> The new buffer will be backed by the given float array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity will be * <tt>array.length</tt>, its position will be <tt>offset</tt>, its limit * will be <tt>offset + length</tt>, and its mark will be undefined. Its * {@link #array </code>backing array<code>} will be the given array, and * its {@link #arrayOffset </code>array offset<code>} will be zero. </p> * * @param array * The array that will back the new buffer * * @param offset * The offset of the subarray to be used; must be non-negative and * no larger than <tt>array.length</tt>. The new buffer's position * will be set to this value. * * @param length * The length of the subarray to be used; * must be non-negative and no larger than * <tt>array.length - offset</tt>. * The new buffer's limit will be set to <tt>offset + length</tt>. * * @return The new float buffer * * @throws IndexOutOfBoundsException * If the preconditions on the <tt>offset</tt> and <tt>length</tt> * parameters do not hold */ public static FloatBuffer wrap(float[] array, int offset, int length) { try { return new HeapFloatBuffer(array, offset, length); } catch (IllegalArgumentException x) { throw new IndexOutOfBoundsException(); } } /** * Wraps a float array into a buffer. * * <p> The new buffer will be backed by the given float array; * that is, modifications to the buffer will cause the array to be modified * and vice versa. The new buffer's capacity and limit will be * <tt>array.length</tt>, its position will be zero, and its mark will be * undefined. Its {@link #array </code>backing array<code>} will be the * given array, and its {@link #arrayOffset </code>array offset<code>} will * be zero. </p> * * @param array * The array that will back this buffer * * @return The new float buffer */ public static FloatBuffer wrap(float[] array) { return wrap(array, 0, array.length); } /** * Creates a new float buffer whose content is a shared subsequence of * this buffer's content. * * <p> The content of the new buffer will start at this buffer's current * position. Changes to this buffer's content will be visible in the new * buffer, and vice versa; the two buffers' position, limit, and mark * values will be independent. * * <p> The new buffer's position will be zero, its capacity and its limit * will be the number of floats remaining in this buffer, and its mark * will be undefined. The new buffer will be direct if, and only if, this * buffer is direct, and it will be read-only if, and only if, this buffer