Пример #1
0
 public override ByteBufferN put(ByteBufferN src)
 {
     if (src is HeapByteBufferN)
     {
         if (src == this)
         {
             throw new IllegalArgumentException();
         }
         var sb = (HeapByteBufferN)src;
         int n  = sb.remaining();
         if (n > remaining())
         {
             throw new BufferOverflowException();
         }
         Array.Copy(sb.hb, sb.ix(sb.position()),
                    hb, ix(position()), n);
         sb.position(sb.position() + n);
         position(position() + n);
     }
     else if (src.isDirect())
     {
         int n = src.remaining();
         if (n > remaining())
         {
             throw new BufferOverflowException();
         }
         src.get(hb, ix(position()), n);
         position(position() + n);
     }
     else
     {
         base.put(src);
     }
     return(this);
 }
Пример #2
0
 private static void checkSlice(ByteBufferN b, ByteBufferN slice)
 {
     ck(slice, 0, slice.position());
     ck(slice, b.remaining(), slice.limit());
     ck(slice, b.remaining(), slice.capacity());
     if (b.isDirect() != slice.isDirect())
     {
         fail("Lost direction", slice);
     }
     if (b.isReadOnly() != slice.isReadOnly())
     {
         fail("Lost read-only", slice);
     }
 }