Class IntrusiveList<T extends IntrusiveListEntry<T>>

  • Type Parameters:
    T - element type
    All Implemented Interfaces:
    IntrusiveListEntry<T>, Iterable<T>, net.automatalib.common.smartcollection.ElementReference, net.automatalib.common.smartcollection.LinkedListEntry<T,​IntrusiveListEntry<T>>
    Direct Known Subclasses:
    TransList

    public class IntrusiveList<T extends IntrusiveListEntry<T>>
    extends AbstractIntrusiveListEntryImpl<T>
    implements Iterable<T>
    A list that stores elements which directly expose information about their predecessor and successor elements. Similar to IntrusiveLinkedList, this list uses doubly-linked entries. However, its elements can remove themselves from the list they are currently part of. In order to ease the management of the start (head) of the list, the list itself is the first element so that removal only requires predecessor/successor pointer management.
    • Constructor Detail

      • IntrusiveList

        public IntrusiveList()
    • Method Detail

      • add

        public void add​(T elem)
        Adds an element to the front of the list. Note that this method also removes the element from the list it may currently be contained in.
        Parameters:
        elem - the element to add
      • concat

        public void concat​(IntrusiveList<T> list)
        Concatenates (prepends) the given list with this list. The given list will be empty after this method terminates.
        Parameters:
        list - the list to add to this list
      • choose

        public @Nullable T choose()
        Retrieves any element from the list. If the list is empty, null is returned.
        Returns:
        any block from the list, or null if the list is empty.
      • poll

        public @Nullable T poll()
        Retrieves and removes the first element from this list.
        Returns:
        the head of the list, or null if the list is empty
      • size

        public int size()
        Returns this size of this list, i.e., the number of elements excluding the self-referential head reference.
        Returns:
        the size of the list
      • isEmpty

        public boolean isEmpty()
        Returns whether this list is empty.
        Returns:
        true if the list is empty, false otherwise