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

            buf.limit    = other.Limit;
            buf.position = other.Position;
            buf.mark     = markOfOther;
            return(buf);
        }
Beispiel #2
0
        /**
         * Creates a new int buffer by wrapping the given int 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 int 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 int buffer.
         * @exception IndexOutOfBoundsException
         *                if either {@code start} or {@code len} is invalid.
         */
        public static Int32Buffer Wrap(int[] array, int start, int len)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }
            if (start < 0 || len < 0 || (long)len + (long)start > array.Length)
            {
                throw new IndexOutOfRangeException();
            }

            Int32Buffer buf = new ReadWriteInt32ArrayBuffer(array);

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

            return(buf);
        }