CircularList { public E removeTop() { if (size() == 0) return null; E top = _elements.remove(_currentPos); if (_currentPos == size()) _currentPos = 0; return top; } CircularList(int initialCapacity);  CircularList();  CircularList(List<E> list);  CircularList(Collection<E> list); void add(E element); E getTop(); E getTail(); E getNext(); void moveToEnd(); void moveToMid(); E removeTop(); boolean remove(E element); int size(); boolean isEmpty(); @Override String toString(); List<E> asList();  }
@Test public void testRemoveTop() { CircularList<Integer> list = new CircularList<Integer>(); int valueCount = 10; for (int i = 0; i < valueCount; i++) { list.add(new Integer(i)); } assertEquals(new Integer(valueCount - 1), list.getTop()); list.removeTop(); assertEquals(new Integer(valueCount - 2), list.getTop()); for (int i = list.size(); i > 0; i--) { assertEquals(new Integer(list.size() - 1), list.removeTop()); } assertEquals(0, list.size()); assertEquals(null, list.removeTop()); assertEquals(null, list.getNext()); assertEquals(null, list.getTop()); list.moveToEnd(); list.moveToMid(); }