@Test public void testPutPartial() { int capacity = 16; CircularByteBuffer buffer = new CircularByteBuffer(capacity); byte[] bytes = createBytes(10); assertEquals(10, buffer.put(bytes)); assertEquals(6, buffer.put(bytes)); assertEquals(0, buffer.put(bytes)); getAndAssertEqualContent(buffer, new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6}); }
public synchronized boolean put(byte value) { if (available == capacity) { return false; } buffer[idxPut] = value; idxPut = (idxPut + 1) % capacity; available++; return true; }
CircularByteBuffer { public synchronized boolean put(byte value) { if (available == capacity) { return false; } buffer[idxPut] = value; idxPut = (idxPut + 1) % capacity; available++; return true; } }
CircularByteBuffer { public synchronized boolean put(byte value) { if (available == capacity) { return false; } buffer[idxPut] = value; idxPut = (idxPut + 1) % capacity; available++; return true; } CircularByteBuffer();  CircularByteBuffer(int capacity); }
CircularByteBuffer { public synchronized boolean put(byte value) { if (available == capacity) { return false; } buffer[idxPut] = value; idxPut = (idxPut + 1) % capacity; available++; return true; } CircularByteBuffer();  CircularByteBuffer(int capacity); synchronized void clear(); synchronized int get(); int get(byte[] dst); synchronized int get(byte[] dst, int off, int len); synchronized boolean put(byte value); int put(byte[] src); synchronized int put(byte[] src, int off, int len); synchronized int peek(); synchronized int skip(int count); int capacity(); synchronized int available(); synchronized int free(); }
CircularByteBuffer { public synchronized boolean put(byte value) { if (available == capacity) { return false; } buffer[idxPut] = value; idxPut = (idxPut + 1) % capacity; available++; return true; } CircularByteBuffer();  CircularByteBuffer(int capacity); synchronized void clear(); synchronized int get(); int get(byte[] dst); synchronized int get(byte[] dst, int off, int len); synchronized boolean put(byte value); int put(byte[] src); synchronized int put(byte[] src, int off, int len); synchronized int peek(); synchronized int skip(int count); int capacity(); synchronized int available(); synchronized int free();  }