@Test public void testWindowStretchingAndShrinking() { int capacity = 1000; double stretchingFactor = 0.25; int extra = (int) (capacity * stretchingFactor); SlidingWindowList<Integer> list = new SlidingWindowList<>(capacity, stretchingFactor); for (int i = 1; i <= 100 * capacity; i++) { list.add(i); if (i <= capacity) { eq(list.size(), i); } else { int size = capacity + i % extra; eq(list.size(), size); } } }
@Override public boolean add(E element) { boolean ret = super.add(element); truncateIfTooBig(); return ret; }
SlidingWindowList extends AbstractListDecorator<E> { @Override public boolean add(E element) { boolean ret = super.add(element); truncateIfTooBig(); return ret; } }
SlidingWindowList extends AbstractListDecorator<E> { @Override public boolean add(E element) { boolean ret = super.add(element); truncateIfTooBig(); return ret; } SlidingWindowList(int maxSize);  SlidingWindowList(int maxSize, double stretchingFactor); }
SlidingWindowList extends AbstractListDecorator<E> { @Override public boolean add(E element) { boolean ret = super.add(element); truncateIfTooBig(); return ret; } SlidingWindowList(int maxSize);  SlidingWindowList(int maxSize, double stretchingFactor); @Override boolean add(E element); @Override void add(int index, E element); @Override boolean addAll(Collection<? extends E> elements); @Override boolean addAll(int index, Collection<? extends E> elements); }
SlidingWindowList extends AbstractListDecorator<E> { @Override public boolean add(E element) { boolean ret = super.add(element); truncateIfTooBig(); return ret; } SlidingWindowList(int maxSize);  SlidingWindowList(int maxSize, double stretchingFactor); @Override boolean add(E element); @Override void add(int index, E element); @Override boolean addAll(Collection<? extends E> elements); @Override boolean addAll(int index, Collection<? extends E> elements);  }