Class PersistentLinkedList<T>

  • All Implemented Interfaces:
    Iterable<T>, Collection<T>, List<T>, PersistentList<T>

    @Immutable(containerOf="T")
    public final class PersistentLinkedList<T>
    extends AbstractSequentialList<T>
    implements PersistentList<T>
    A single-linked-list implementation of PersistentList. Null values are not supported (similarly to ImmutableList).

    Adding to the front of the list needs only O(1) time and memory.

    This implementation supports almost all operations, except for the ListIterator.hasPrevious() and ListIterator.previous() methods of its list iterator. This means you cannot traverse this list in reverse order.

    All instances of this class are fully-thread safe. However, note that each modifying operation allocates a new instance whose reference needs to be published safely in order to be usable by other threads. Two concurrent accesses to a modifying operation on the same instance will create two new maps, each reflecting exactly the operation executed by the current thread, and not reflecting the operation executed by the other thread.