CircularList { public void moveToMid() { if (size() == 0) return; E element = _elements.remove(_currentPos); int midPos = size() / 2 + _currentPos; if (midPos > size()) midPos -= size(); _elements.add(midPos, element); } 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 testMoveToMid() { 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.moveToMid(); assertEquals(new Integer(valueCount - 2), list.getTop()); for (int i = 0; i < (valueCount - 1) / 2; i++) { list.getNext(); } assertEquals(new Integer(valueCount - 1), list.getTop()); for (int i = 0; i < (valueCount) / 2; i++) { list.moveToMid(); } assertEquals(new Integer(valueCount - 1), list.getTop()); }