예제 #1
0
 internal static CharSequenceAdapter Copy(CharSequenceAdapter other)
 {
     return(new CharSequenceAdapter(other.sequence)
     {
         limit = other.limit,
         position = other.position,
         mark = other.mark
     });
 }
예제 #2
0
        public override CharBuffer Subsequence(int startIndex, int length)
        {
            if (startIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(startIndex));
            }
            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }
            if (startIndex > Remaining - length) // Checks for int overflow
            {
                throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_IndexLength);
            }

            CharSequenceAdapter result = Copy(this);

            result.position = position + startIndex;
            result.limit    = position + startIndex + length;
            return(result);
        }
예제 #3
0
        public override CharBuffer Subsequence(int startIndex, int length)
        {
            if (startIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(startIndex));
            }
            if (length < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }
            if (startIndex + length > Remaining)
            {
                throw new ArgumentOutOfRangeException("", $"{nameof(startIndex)} + {nameof(length)} > {nameof(Remaining)}");
            }

            CharSequenceAdapter result = Copy(this);

            result.position = position + startIndex;
            result.limit    = position + startIndex + length;
            return(result);
        }