Dllist.Xt
Explicit transaction log passing on doubly-linked lists.
remove n
removes the node n
from the doubly-linked list it is part of. remove
is idempotent.
move_l n l
removes the node n
from the doubly-linked list it is part of and then adds it to the left of the list l
.
move_r n l
removes the node n
from the doubly-linked list it is part of and then adds it to the right of the list l
.
is_empty l
determines whether the doubly-linked list l
is empty or not.
add_l v l
creates and returns a new node with the value v
and adds the node to the left of the doubly-linked list l
.
add_r v l
creates and returns a new node with the value v
and adds the node to the right of the doubly-linked list l
.
take_opt_l l
removes and returns the value of leftmost node of the doubly-linked list l
, or return None
if the list is empty.
take_opt_r l
removes and returns the value of rightmost node of the doubly-linked list l
, or return None
if the list is empty.
take_blocking_l l
removes and returns the value of leftmost node of the doubly-linked list l
, or blocks waiting for the list to become non-empty.
take_blocking_r l
removes and returns the value of rightmost node of the doubly-linked list l
, or blocks waiting for the list to become non-empty.
swap l1 l2
exchanges the nodes of the doubly-linked lists l1
and l2
.
transfer_l l1 l2
removes all nodes of l1
and adds them to the left of l2
.
transfer_r l1 l2
removes all nodes of l1
and adds them to the right of l2
.
to_list_l l
collects the values of the nodes of the doubly-linked list l
to a list in left-to-right order.
NOTE: This operation is linear time, O(n)
, and should typically be avoided unless the list is privatized, e.g. by using take_all
.
to_list_r l
collects the values of the nodes of the doubly-linked list l
to a list in right-to-left order.
NOTE: This operation is linear time, O(n)
, and should typically be avoided unless the list is privatized, e.g. by using take_all
.
to_nodes_l l
collects the nodes of the doubly-linked list l
to a list in left-to-right order.
NOTE: This operation is linear time, O(n)
, and should typically be avoided unless the list is privatized, e.g. by using take_all
.