1451 lines · 28.5 KB · Java
RawDownload
/* * 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 short buffer. * * <p> This class defines four categories of operations upon * short buffers: * * <ul> * *   <li><p> Absolute and relative {@link #get() </code><i>get</i><code>} and *   {@link #put(short) </code><i>put</i><code>} methods that read and write *   single shorts; </p></li> * *   <li><p> Relative {@link #get(short[]) </code><i>bulk get</i><code>} *   methods that transfer contiguous sequences of shorts from this buffer *   into an array; and</p></li> * *   <li><p> Relative {@link #put(short[]) </code><i>bulk put</i><code>} *   methods that transfer contiguous sequences of shorts from a *   short array or some other short *   buffer into this buffer;&#32;and </p></li> *             * *   <li><p> Methods for {@link #compact </code>compacting<code>}, {@link *   #duplicate </code>duplicating<code>}, and {@link #slice *   </code>slicing<code>} a short buffer.  </p></li> * * </ul> * * <p> Short buffers can be created either by {@link #allocate * </code><i>allocation</i><code>}, which allocates space for the buffer's *       * * content, by {@link #wrap(short[]) </code><i>wrapping</i><code>} an existing * short 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 short buffer is either <a * href="ByteBuffer.html#direct"><i>direct</i> or <i>non-direct</i></a>.  A * short buffer created via the <tt>wrap</tt> methods of this class will * be non-direct.  A short 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 short 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 ShortBuffer    extends Buffer    implements Comparable<ShortBuffer>{     // 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 short[] 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    //    ShortBuffer(int mark, int pos, int lim, int cap,   // package-private                 short[] 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    //    ShortBuffer(int mark, int pos, int lim, int cap) { // package-private        this(mark, pos, lim, cap, null, 0);    }                             /**     * Allocates a new short 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 shorts     *     * @return  The new short buffer     *     * @throws  IllegalArgumentException     *          If the <tt>capacity</tt> is a negative integer     */    public static ShortBuffer allocate(int capacity) {        if (capacity < 0)            throw new IllegalArgumentException();        return new HeapShortBuffer(capacity, capacity);    }     /**     * Wraps a short array into a buffer.     *     * <p> The new buffer will be backed by the given short 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 short buffer     *     * @throws  IndexOutOfBoundsException     *          If the preconditions on the <tt>offset</tt> and <tt>length</tt>     *          parameters do not hold     */    public static ShortBuffer wrap(short[] array,                                    int offset, int length)    {        try {            return new HeapShortBuffer(array, offset, length);        } catch (IllegalArgumentException x) {            throw new IndexOutOfBoundsException();        }    }     /**     * Wraps a short array into a buffer.     *     * <p> The new buffer will be backed by the given short 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 short buffer     */    public static ShortBuffer wrap(short[] array) {        return wrap(array, 0, array.length);    }                                                                                                  /**     * Creates a new short 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 shorts 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

Lines 1–500 of 1451.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t