internal static ReadWriteInt16ArrayBuffer Copy(Int16ArrayBuffer other,
                                                       int markOfOther)
        {
            ReadWriteInt16ArrayBuffer buf = new ReadWriteInt16ArrayBuffer(other
                                                                          .Capacity, other.backingArray, other.offset);

            buf.limit    = other.Limit;
            buf.position = other.Position;
            buf.mark     = markOfOther;
            return(buf);
        }
Esempio n. 2
0
        /**
         * Creates a new short buffer by wrapping the given short array.
         * <p>
         * The new buffer's position will be {@code start}, limit will be
         * {@code start + len}, capacity will be the length of the array.
         *
         * @param array
         *            the short array which the new buffer will be based on.
         * @param start
         *            the start index, must not be negative and not greater than
         *            {@code array.length}.
         * @param len
         *            the length, must not be negative and not greater than
         *            {@code array.length - start}.
         * @return the created short buffer.
         * @exception IndexOutOfBoundsException
         *                if either {@code start} or {@code len} is invalid.
         */
        public static Int16Buffer Wrap(short[] array, int start, int len)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }
            if (start < 0 || len < 0 || (long)start + (long)len > array.Length)
            {
                throw new IndexOutOfRangeException();
            }

            Int16Buffer buf = new ReadWriteInt16ArrayBuffer(array);

            buf.position = start;
            buf.limit    = start + len;

            return(buf);
        }