@Test public void testRemove() throws Exception { ByteArrayBuffer b = new ByteArrayBuffer(16); byte tmp[] = "--+++-".getBytes("US-ASCII"); b.append(tmp, 0, tmp.length); b.remove(2, 3); Assert.assertEquals(3, b.length()); Assert.assertEquals("---", new String(b.buffer(), 0, b.length(), "US-ASCII")); b.remove(2, 1); b.remove(1, 1); b.remove(0, 1); Assert.assertEquals(0, b.length()); tmp = "+++---".getBytes("US-ASCII"); b.append(tmp, 0, tmp.length); b.remove(0, 3); Assert.assertEquals(3, b.length()); Assert.assertEquals("---", new String(b.buffer(), 0, b.length(), "US-ASCII")); b.remove(0, 3); Assert.assertEquals(0, b.length()); tmp = "---+++".getBytes("US-ASCII"); b.append(tmp, 0, tmp.length); b.remove(3, 3); Assert.assertEquals(3, b.length()); Assert.assertEquals("---", new String(b.buffer(), 0, b.length(), "US-ASCII")); b.remove(0, 3); Assert.assertEquals(0, b.length()); }
public void remove(int off, int len) { if ((off < 0) || (off > this.len) || (len < 0) || ((off + len) < 0) || ((off + len) > this.len)) { throw new IndexOutOfBoundsException(); } if (len == 0) { return; } int remaining = this.len - off - len; if (remaining > 0) { System.arraycopy(this.buffer, off + len, this.buffer, off, remaining); } this.len -= len; }
ByteArrayBuffer implements ByteSequence { public void remove(int off, int len) { if ((off < 0) || (off > this.len) || (len < 0) || ((off + len) < 0) || ((off + len) > this.len)) { throw new IndexOutOfBoundsException(); } if (len == 0) { return; } int remaining = this.len - off - len; if (remaining > 0) { System.arraycopy(this.buffer, off + len, this.buffer, off, remaining); } this.len -= len; } }
ByteArrayBuffer implements ByteSequence { public void remove(int off, int len) { if ((off < 0) || (off > this.len) || (len < 0) || ((off + len) < 0) || ((off + len) > this.len)) { throw new IndexOutOfBoundsException(); } if (len == 0) { return; } int remaining = this.len - off - len; if (remaining > 0) { System.arraycopy(this.buffer, off + len, this.buffer, off, remaining); } this.len -= len; } ByteArrayBuffer(int capacity);  ByteArrayBuffer(byte[] bytes, boolean dontCopy);  ByteArrayBuffer(byte[] bytes, int len, boolean dontCopy); }
ByteArrayBuffer implements ByteSequence { public void remove(int off, int len) { if ((off < 0) || (off > this.len) || (len < 0) || ((off + len) < 0) || ((off + len) > this.len)) { throw new IndexOutOfBoundsException(); } if (len == 0) { return; } int remaining = this.len - off - len; if (remaining > 0) { System.arraycopy(this.buffer, off + len, this.buffer, off, remaining); } this.len -= len; } ByteArrayBuffer(int capacity);  ByteArrayBuffer(byte[] bytes, boolean dontCopy);  ByteArrayBuffer(byte[] bytes, int len, boolean dontCopy); void append(final byte[] b, int off, int len); void append(int b); void clear(); byte[] toByteArray(); byte byteAt(int i); int capacity(); int length(); byte[] buffer(); int indexOf(byte b); int indexOf(byte b, int beginIndex, int endIndex); void setLength(int len); void remove(int off, int len); boolean isEmpty(); boolean isFull(); @Override String toString(); }
ByteArrayBuffer implements ByteSequence { public void remove(int off, int len) { if ((off < 0) || (off > this.len) || (len < 0) || ((off + len) < 0) || ((off + len) > this.len)) { throw new IndexOutOfBoundsException(); } if (len == 0) { return; } int remaining = this.len - off - len; if (remaining > 0) { System.arraycopy(this.buffer, off + len, this.buffer, off, remaining); } this.len -= len; } ByteArrayBuffer(int capacity);  ByteArrayBuffer(byte[] bytes, boolean dontCopy);  ByteArrayBuffer(byte[] bytes, int len, boolean dontCopy); void append(final byte[] b, int off, int len); void append(int b); void clear(); byte[] toByteArray(); byte byteAt(int i); int capacity(); int length(); byte[] buffer(); int indexOf(byte b); int indexOf(byte b, int beginIndex, int endIndex); void setLength(int len); void remove(int off, int len); boolean isEmpty(); boolean isFull(); @Override String toString();  }