One of the general purpose implementations of the List interface is LinkedList.
Interfaces implemented - List, Queue, Deque, Collection, Iterable, Cloneable, Serializable
Classes extends from - AbstractCollection, AbstractList, AbstractSequentialList
Structurally, it maintains a nested private static class Node using which the doubly linked list is implemented.
Features
Interfaces implemented - List, Queue, Deque, Collection, Iterable, Cloneable, Serializable
Classes extends from - AbstractCollection, AbstractList, AbstractSequentialList
Structurally, it maintains a nested private static class Node using which the doubly linked list is implemented.
Features
- sequential access data structure (NO random access)
- non-synchronized data structure (Collections.synchronizedList() can be used to reverse the behavior)
- Iterator and ListIterator returned from LinkedList are fail-fast (throws ConcurrentModificationException when the structure changes by any method other than the iterators' methods)
- insertion order is retained in LinkedList
- has seven optional operations - clone, addFirst, getFirst, removeFirst, addLast, getLast, and removeLast
- O(n) when it comes to search as the LinkedList maintains a doubly linked list which needs traversal through all the elements to find an entry
- O(1) for insertion and deletion as its just a matter for adding and removing a node and adjusting the two pointers of that node.
Comments