Пример #1
0
        internal static ReadWriteCharArrayBuffer Copy(CharArrayBuffer other, int markOfOther)
        {
            ReadWriteCharArrayBuffer buf = new ReadWriteCharArrayBuffer(other
                                                                        .Capacity, other.backingArray, other.offset);

            buf.limit    = other.Limit;
            buf.position = other.Position;
            buf.mark     = markOfOther;
            return(buf);
        }
Пример #2
0
        /**
         * Creates a new char buffer by wrapping the given char 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 char 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 char buffer.
         * @exception IndexOutOfBoundsException
         *                if either {@code start} or {@code len} is invalid.
         */
        public static CharBuffer Wrap(char[] array, int start, int len)
        {
            int length = array.Length;

            if ((start < 0) || (len < 0) || (long)start + (long)len > length)
            {
                throw new IndexOutOfRangeException();
            }

            CharBuffer buf = new ReadWriteCharArrayBuffer(array);

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

            return(buf);
        }