Linked Lists | Contents |
Linked lists are mutable sequences that consist of nodes which are linked with next pointers. They are supported by class LinkedList. In most languages null would be picked as the empty linked list. That does not work for Scala collections, because even empty sequences must support all sequence methods. In particular LinkedList.empty.isEmpty should return true and not throw a NullPointerException. Empty linked lists are encoded instead in a special way: Their next field points back to the node itself. Like their immutable cousins, linked lists are best traversed sequentially. In addition linked lists make it easy to insert an element or linked list into another linked list.
Next: Double Linked Lists
Linked Lists | Contents |