Module de.learnlib.datastructure
Package de.learnlib.datastructure.list
Class IntrusiveList<T extends IntrusiveListEntry<T>>
- java.lang.Object
-
- net.automatalib.common.smartcollection.AbstractBasicLinkedListEntry<T,IntrusiveListEntry<T>>
-
- de.learnlib.datastructure.list.AbstractIntrusiveListEntryImpl<T>
-
- de.learnlib.datastructure.list.IntrusiveList<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 toIntrusiveLinkedList
, this list uses doubly-linked entries. However, its elements canremove
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 Summary
Constructors Constructor Description IntrusiveList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T elem)
Adds an element to the front of the list.@Nullable T
choose()
Retrieves any element from the list.void
concat(IntrusiveList<T> list)
Concatenates (prepends) the given list withthis
list.T
getElement()
boolean
isEmpty()
Returns whether this list is empty.Iterator<T>
iterator()
@Nullable T
poll()
Retrieves and removes the first element from this list.int
size()
Returns this size of this list, i.e., the number of elements excluding the self-referential head reference.-
Methods inherited from class net.automatalib.common.smartcollection.AbstractBasicLinkedListEntry
getNext, getPrev, setNext, setPrev
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.learnlib.datastructure.list.IntrusiveListEntry
removeFromList
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
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 withthis
list. The given list will be empty after this method terminates.- Parameters:
list
- the list to add tothis
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
-
iterator
public Iterator<T> iterator()
- Specified by:
iterator
in interfaceIterable<T extends IntrusiveListEntry<T>>
-
getElement
public T getElement()
- Specified by:
getElement
in interfacenet.automatalib.common.smartcollection.LinkedListEntry<T extends IntrusiveListEntry<T>,IntrusiveListEntry<T extends IntrusiveListEntry<T>>>
-
-