@Test public void testAdd() { CircularBuffer<Elems> eb = new CircularBuffer<Elems>(2); Elems theone = new Elems("String 1", false); Elems ret1 = eb.add(theone); assertEquals(null, ret1); Elems ret2 = eb.add(new Elems("String 2", true)); assertEquals(null, ret2); Elems ret3 = eb.add(new Elems("String 3", true)); assertEquals(true, ret3 == theone); log.info("{} {}", ret3, theone); }
public T add(T e) { T oldE = null; while (!buffer.offerLast(e)) { oldE = buffer.poll(); } return oldE; }
CircularBuffer implements Iterable<T> { public T add(T e) { T oldE = null; while (!buffer.offerLast(e)) { oldE = buffer.poll(); } return oldE; } }
CircularBuffer implements Iterable<T> { public T add(T e) { T oldE = null; while (!buffer.offerLast(e)) { oldE = buffer.poll(); } return oldE; } CircularBuffer(int capacity); }
CircularBuffer implements Iterable<T> { public T add(T e) { T oldE = null; while (!buffer.offerLast(e)) { oldE = buffer.poll(); } return oldE; } CircularBuffer(int capacity); T add(T e); ArrayList<T> addAll(ArrayList<T> elist, int uptoIndex); @Override Iterator<T> iterator(); int size(); void clear(); }
CircularBuffer implements Iterable<T> { public T add(T e) { T oldE = null; while (!buffer.offerLast(e)) { oldE = buffer.poll(); } return oldE; } CircularBuffer(int capacity); T add(T e); ArrayList<T> addAll(ArrayList<T> elist, int uptoIndex); @Override Iterator<T> iterator(); int size(); void clear();  }