public override CharBuffer Put(CharBuffer src) { if (src is DirectCharBufferS) { if (src == this) { throw new IllegalArgumentException(); } DirectCharBufferS sb = (DirectCharBufferS)src; int spos = sb.Position(); int slim = sb.Limit(); assert(spos <= slim); int srem = (spos <= slim ? slim - spos : 0); int pos = Position(); int lim = Limit(); assert(pos <= lim); int rem = (pos <= lim ? lim - pos : 0); if (srem > rem) { throw new BufferOverflowException(); } @unsafe.copyMemory(sb.Ix(spos), Ix(pos), (long)srem << 1); sb.Position(spos + srem); Position(pos + srem); } else if (src.Hb != null) { int spos = src.Position(); int slim = src.Limit(); assert(spos <= slim); int srem = (spos <= slim ? slim - spos : 0); Put(src.Hb, src.Offset + spos, srem); src.Position(spos + srem); } else { base.Put(src); } return(this); }
public override String ToString(int start, int end) { if ((end > Limit()) || (start > end)) { throw new IndexOutOfBoundsException(); } try { int len = end - start; char[] ca = new char[len]; CharBuffer cb = CharBuffer.Wrap(ca); CharBuffer db = this.Duplicate(); db.Position(start); db.Limit(end); cb.Put(db); return(new String(ca)); } catch (StringIndexOutOfBoundsException) { throw new IndexOutOfBoundsException(); } }
internal CharBufferSpliterator(CharBuffer buffer) : this(buffer, buffer.Position(), buffer.Limit()) { }