qblox_scheduler.helpers.linked_list#
Doubly linked list.
Attributes#
Classes#
A node in a |
|
A doubly linked list. |
Module Contents#
- class DLinkedListNode(value: T, prev: DLinkedListNode[T] | None = None, next: DLinkedListNode[T] | None = None)[source]#
Bases:
Generic[T]A node in a
DLinkedList.- property prev: DLinkedListNode[T] | None[source]#
The node before this one.
- property next: DLinkedListNode[T] | None[source]#
The node after this one.
- class DLinkedList(from_iterable: collections.abc.Iterable[T] | None = None)[source]#
Bases:
collections.abc.MutableSequence[T]A doubly linked list.
- __head: DLinkedListNode[T] | None = None[source]#
- __tail: DLinkedListNode[T] | None = None[source]#
- node_at(index: int) DLinkedListNode[T][source]#
Return the
DLinkedListNodeat the index.
- iter_nodes(*, reverse: bool = False) collections.abc.Iterator[DLinkedListNode[T]][source]#
Return an iterator of the nodes of the list.
- insert_after(node: DLinkedListNode[T], value: T) None[source]#
Insert value into the list after the given node.
- insert_before(node: DLinkedListNode[T], value: T) None[source]#
Insert value into the list before the given node.
- index(value: T, start: int = 0, stop: int = ...) int[source]#
Return first index of value.
Raises ValueError if the value is not present. Optional arguments start and end are interpreted as in slice notation.
- extend(values: collections.abc.Iterable[T]) None[source]#
Extend the right side of the list by appending elements from the iterable argument.
- pop(index: int = -1) T[source]#
Remove and return an element from the list at index.
By default, removes from the right side of the list. If no elements are present, raises an IndexError.
- remove(value: T) None[source]#
Remove the first occurrence of value. If not found, raises a ValueError.
- copy() DLinkedList[T][source]#
Create a shallow copy of the linked list.
- extendleft(values: collections.abc.Iterable[T]) None[source]#
Extend the left side of the linked list by appending elements from iterable.
Note, the series of left appends results in reversing the order of elements in the iterable argument.