@Test public void testFillBuffer() { final int capacity = 5; final ICircularBuffer<String> buffer = CircularBuffer.create(capacity); buffer.add("A"); buffer.add("B"); buffer.add("C"); Assert.assertEquals(3, buffer.size()); assertBufferHasStringValues(buffer, "A", "B", "C"); buffer.fill("FOO"); Assert.assertEquals(capacity, buffer.size()); assertBufferHasStringValues(buffer, "A", "B", "C", "FOO", "FOO"); buffer.add("D"); assertBufferHasStringValues(buffer, "B", "C", "FOO", "FOO", "D"); buffer.fill(); assertBufferHasStringValues(buffer, "B", "C", "FOO", "FOO", "D"); buffer.clear(); buffer.add("1"); buffer.add("2"); buffer.add("3"); buffer.add("4"); buffer.add("5"); buffer.add("6"); buffer.removeLast(); Assert.assertEquals(4, buffer.size()); assertBufferHasStringValues(buffer, "2", "3", "4", "5", null); buffer.fill(); Assert.assertEquals(5, buffer.size()); assertBufferHasStringValues(buffer, "2", "3", "4", "5", null); buffer.add("7"); assertBufferHasStringValues(buffer, "3", "4", "5", null, "7"); buffer.setSize(2); Assert.assertEquals(2, buffer.size()); assertBufferHasStringValues(buffer, "3", "4", null, null, null); buffer.fill(); Assert.assertEquals(5, buffer.size()); assertBufferHasStringValues(buffer, "3", "4", null, null, null); buffer.removeLast(); buffer.removeLast(); buffer.removeLast(); Assert.assertEquals(2, buffer.size()); assertBufferHasStringValues(buffer, "3", "4", null, null, null); buffer.fill(); Assert.assertEquals(5, buffer.size()); assertBufferHasStringValues(buffer, "3", "4", null, null, null); }
public static <ELEMENT_TYPE> ICircularBuffer<ELEMENT_TYPE> create(final int capacity) { return new CircularBufferImpl<ELEMENT_TYPE>(capacity); }
CircularBuffer { public static <ELEMENT_TYPE> ICircularBuffer<ELEMENT_TYPE> create(final int capacity) { return new CircularBufferImpl<ELEMENT_TYPE>(capacity); } }
CircularBuffer { public static <ELEMENT_TYPE> ICircularBuffer<ELEMENT_TYPE> create(final int capacity) { return new CircularBufferImpl<ELEMENT_TYPE>(capacity); } private  CircularBuffer(); }
CircularBuffer { public static <ELEMENT_TYPE> ICircularBuffer<ELEMENT_TYPE> create(final int capacity) { return new CircularBufferImpl<ELEMENT_TYPE>(capacity); } private  CircularBuffer(); static ICircularBuffer<ELEMENT_TYPE> create(final int capacity); }
CircularBuffer { public static <ELEMENT_TYPE> ICircularBuffer<ELEMENT_TYPE> create(final int capacity) { return new CircularBufferImpl<ELEMENT_TYPE>(capacity); } private  CircularBuffer(); static ICircularBuffer<ELEMENT_TYPE> create(final int capacity);  }