/** * Returns a cursor iterator that allows changes to the underlying list in parallel. * <p> * The cursor enables iteration and list changes to occur in any order without * invalidating the iterator (from one thread). When elements are added to the * list, an event is fired to all active cursors enabling them to adjust to the * change in the list. * <p> * When the "current" (i.e., last returned by {@link ListIterator#next} * or {@link ListIterator#previous}) element of the list is removed, * the cursor automatically adjusts to the change (invalidating the * last returned value such that it cannot be removed). * * @return a new cursor iterator */ @Override public ListIterator<E> listIterator() { return cursor(0); }
/** * Returns a cursor iterator that allows changes to the underlying list in parallel. * <p> * The cursor enables iteration and list changes to occur in any order without * invalidating the iterator (from one thread). When elements are added to the * list, an event is fired to all active cursors enabling them to adjust to the * change in the list. * <p> * When the "current" (i.e., last returned by {@link ListIterator#next} * or {@link ListIterator#previous}) element of the list is removed, * the cursor automatically adjusts to the change (invalidating the * last returned value such that it cannot be removed). * * @param fromIndex the index to start from * @return a new cursor iterator */ @Override public ListIterator<E> listIterator(final int fromIndex) { return cursor(fromIndex); }
/** * Returns a {@link Cursor} for iterating through the elements of this list. * <p> * A <code>Cursor</code> is a <code>ListIterator</code> with an additional * <code>close()</code> method. Calling this method immediately discards the * references to the cursor. If it is not called, then the garbage collector * will still remove the reference as it is held via a <code>WeakReference</code>. * <p> * The cursor enables iteration and list changes to occur in any order without * invalidating the iterator (from one thread). When elements are added to the * list, an event is fired to all active cursors enabling them to adjust to the * change in the list. * <p> * When the "current" (i.e., last returned by {@link ListIterator#next} * or {@link ListIterator#previous}) element of the list is removed, * the cursor automatically adjusts to the change (invalidating the * last returned value such that it cannot be removed). * <p> * The {@link #listIterator()} method returns the same as this method, and can * be cast to a <code>Cursor</code> if the <code>close</code> method is required. * * @return a new cursor iterator */ public CursorableLinkedList.Cursor<E> cursor() { return cursor(0); }