9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.util; 27 28 /** 29 * Linked list implementation of the {@link List} and {@link Deque} interfaces. 30 * Implements all optional operations, and permits all elements (including 31 * {@code null}). 32 * 33 * <p>All of the operations perform as could be expected for a doubly-linked 34 * list. Operations that index into the list will traverse the list from 35 * the beginning or the end, whichever is closer to the specified index. 36 * 37 * <p><strong>Note that this implementation is not synchronized.</strong> 38 * If multiple threads access a linked list concurrently, and at least 39 * one of the threads modifies the list structurally, it <i>must</i> be 40 * synchronized externally. (A structural modification is any operation 41 * that adds or deletes one or more elements; merely setting the value of 42 * an element is not a structural modification.) This is typically 43 * accomplished by synchronizing on some object that naturally 44 * encapsulates the list. 45 * 46 * If no such object exists, the list should be "wrapped" using the 47 * {@link Collections#synchronizedList Collections.synchronizedList} 48 * method. This is best done at creation time, to prevent accidental 49 * unsynchronized access to the list:<pre> 50 * List list = Collections.synchronizedList(new LinkedList(...));</pre> 51 * 52 * <p>The iterators returned by this class's {@code iterator} and | 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package java.util; 27 28 /** 29 * Linked list implementation of the {@code List} interface. Implements all 30 * optional list operations, and permits all elements (including 31 * {@code null}). In addition to implementing the {@code List} interface, 32 * the {@code LinkedList} class provides uniformly named methods to 33 * {@code get}, {@code remove} and {@code insert} an element at the 34 * beginning and end of the list. These operations allow linked lists to be 35 * used as a stack, {@linkplain Queue queue}, or {@linkplain Deque 36 * double-ended queue}. 37 * 38 * <p>The class implements the {@code Deque} interface, providing 39 * first-in-first-out queue operations for {@code add}, 40 * {@code poll}, along with other stack and deque operations. 41 * 42 * <p>All of the operations perform as could be expected for a doubly-linked 43 * list. Operations that index into the list will traverse the list from 44 * the beginning or the end, whichever is closer to the specified index. 45 * 46 * <p><strong>Note that this implementation is not synchronized.</strong> 47 * If multiple threads access a linked list concurrently, and at least 48 * one of the threads modifies the list structurally, it <i>must</i> be 49 * synchronized externally. (A structural modification is any operation 50 * that adds or deletes one or more elements; merely setting the value of 51 * an element is not a structural modification.) This is typically 52 * accomplished by synchronizing on some object that naturally 53 * encapsulates the list. 54 * 55 * If no such object exists, the list should be "wrapped" using the 56 * {@link Collections#synchronizedList Collections.synchronizedList} 57 * method. This is best done at creation time, to prevent accidental 58 * unsynchronized access to the list:<pre> 59 * List list = Collections.synchronizedList(new LinkedList(...));</pre> 60 * 61 * <p>The iterators returned by this class's {@code iterator} and |