ReItrLinkedList extends AbstractSequentialList<E> implements List<E>, Deque<E>, Cloneable, java.io.Serializable { public ReusableIterator<E> iterator() { return listIterator(); } ReItrLinkedList();  ReItrLinkedList(Collection<? extends E> c); E getFirst(); E getLast(); E removeFirst(); E removeLast(); void addFirst(E e); void addLast(E e); boolean contains(Object o); int size(); boolean add(E e); boolean remove(Object o); boolean addAll(Collection<? extends E> c); boolean addAll(int index, Collection<? extends E> c); void clear(); E get(int index); E set(int index, E element); void add(int index, E element); E remove(int index); int indexOf(Object o); int lastIndexOf(Object o); E peek(); E element(); E poll(); E remove(); boolean offer(E e); boolean offerFirst(E e); boolean offerLast(E e); E peekFirst(); E peekLast(); E pollFirst(); E pollLast(); void push(E e); E pop(); boolean removeFirstOccurrence(Object o); boolean removeLastOccurrence(Object o); ReusableIterator<E> iterator(); ReusableListIterator<E> listIterator(); ReusableListIterator<E> listIterator(int index); Iterator<E> descendingIterator(); Object clone(); Object[] toArray(); @SuppressWarnings("unchecked") T[] toArray(T[] a);  }
@Test public void iterator() throws Exception { ReItrLinkedList<String> l = new ReItrLinkedList<>(); String[] strs = {"abc", "123", "hehe"}; Collections.addAll(l, strs); ReusableIterator<String> itr = l.iterator(); assertEquals(strs[0], itr.next()); assertEquals(strs[1], itr.next()); ReusableIterator<String> retItr = itr.rewind(); assertTrue(retItr == itr); assertEquals(strs[0], itr.next()); assertEquals(strs[1], itr.next()); assertEquals(strs[2], itr.next()); try { itr.next(); fail("should throw exception"); } catch (NoSuchElementException ignored) { } }