@Test public void testCirculate() { final int capacity = 5; final ICircularBuffer<String> buffer = CircularBuffer.create(capacity); buffer.add("A"); assertBufferHasStringValues(buffer, "A"); Assert.assertEquals(1, buffer.size()); buffer.add("B"); assertBufferHasStringValues(buffer, "A", "B"); Assert.assertEquals(2, buffer.size()); buffer.add("C"); assertBufferHasStringValues(buffer, "A", "B", "C"); Assert.assertEquals(3, buffer.size()); buffer.add("D"); assertBufferHasStringValues(buffer, "A", "B", "C", "D"); Assert.assertEquals(4, buffer.size()); buffer.add("E"); assertBufferHasStringValues(buffer, "A", "B", "C", "D", "E"); Assert.assertEquals(capacity, buffer.size()); buffer.add("F"); assertBufferHasStringValues(buffer, "B", "C", "D", "E", "F"); Assert.assertEquals(capacity, buffer.size()); buffer.add("G"); assertBufferHasStringValues(buffer, "C", "D", "E", "F", "G"); Assert.assertEquals(capacity, buffer.size()); buffer.add("H"); assertBufferHasStringValues(buffer, "D", "E", "F", "G", "H"); Assert.assertEquals(capacity, buffer.size()); buffer.add("I"); assertBufferHasStringValues(buffer, "E", "F", "G", "H", "I"); Assert.assertEquals(capacity, buffer.size()); buffer.add("J"); assertBufferHasStringValues(buffer, "F", "G", "H", "I", "J"); Assert.assertEquals(capacity, buffer.size()); buffer.add(null); assertBufferHasStringValues(buffer, "G", "H", "I", "J", null); Assert.assertEquals(capacity, buffer.size()); buffer.add(null); assertBufferHasStringValues(buffer, "H", "I", "J", null, null); Assert.assertEquals(capacity, buffer.size()); buffer.add(null); assertBufferHasStringValues(buffer, "I", "J", null, null, null); Assert.assertEquals(capacity, buffer.size()); buffer.add(null); assertBufferHasStringValues(buffer, "J", null, null, null, null); Assert.assertEquals(capacity, buffer.size()); buffer.add(null); assertBufferHasStringValues(buffer, null, null, null, null, null); Assert.assertEquals(capacity, buffer.size()); }
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);  }