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