EvictingBoundedList implements Iterable<T>, Serializable { public void clear() { if (!isEmpty()) { for (int i = 0; i < elements.length; ++i) { elements[i] = null; } count = 0; idx = 0; ++modCount; } } EvictingBoundedList(int sizeLimit);  EvictingBoundedList(EvictingBoundedList<T> other);  EvictingBoundedList(int sizeLimit, T defaultElement); int size(); boolean isEmpty(); boolean add(T t); void clear(); T get(int index); int getSizeLimit(); T set(int index, T element); T getDefaultElement(); @Override Iterator<T> iterator(); EvictingBoundedList<R> map(Function<T, R> transform);  }
@Test public void testClear() { int insertSize = 17; int boundSize = 5; Integer defaultElement = 4711; EvictingBoundedList<Integer> list = new EvictingBoundedList<>(boundSize, defaultElement); for (int i = 0; i < insertSize; ++i) { list.add(i); } list.clear(); assertEquals(0, list.size()); assertTrue(list.isEmpty()); try { list.get(0); fail(); } catch (IndexOutOfBoundsException ignore) { } }