#include <bslalg_bidirectionallinklistutil.h>
This struct
provides a namespace for utility functions that manipulate linked lists based on bslalg::BidirectionalLink
nodes, including insertion, removal, and splicing.
◆ insertLinkAfterTarget()
Insert the specified newNode
after the specified target
node in the linked list that contains target
. If the node following target
is 0, then set the nextLink
attribute of newNode
to 0. After successful execution of this function the values of the previousLink
and nextLink
attributes of all the links in the list appropriately reflect the operation. The behavior is undefined unless 0 != newNode
and 0 != target
. The behavior is also undefined unless 0 == target->nextLink()
is true or isWellFormed(target, target->nextLink())
are true.
◆ insertLinkBeforeTarget()
Insert the specified newNode
before the specified target
node in the linked list that contains target
. If target
is 0, then the value of the attributes nextLink
and previousLink
of newNode
is set to 0. After successful execution of this function the values of the previousLink
and nextLink
attributes of all the links in the list appropriately reflect the operation. The behavior is undefined unless 0 == target->previousLink()
is true or isWellFormed(target->previousLink(), target)
is true.
◆ isWellFormed()
Return true if the bidirectional list starting from the specified head
, and ending with the specified tail
is well formed. A bidirectional list is well formed if tail == head
(0 values are allowed) or all of the following conditions are met (note that head
is renamed to h
and tail
to t
for brevity):
h
and t
are valid addresses.
h->nextLink()->previousLink() == h
is true.
!h->previousLink() || h->previousLink()->nextLink() == h
is true.
t->previousLink()->nextLink() == t
is true.
!t->nextLink() || t->nextLink()->previousLink() == t
is true.
- For each
link
in the list different than h
and t
both link->nextLink()->previousLink() == link
and link->previousLink()->nextLink() == link
are true.
The behavior is undefined unless tail
can be reached from head
following the chain of nextLink
attributes of all the nodes in the open range [head, tail)
.
◆ spliceListBeforeTarget()
Unlink and move (splice) the elements of a doubly-linked list included in the closed range [first, last]
out of their original list and into another doubly-linked list before the specified target
node. If target
is 0, then the elements are extracted and form a new list such that 0 == first->previousLink()
and 0 == last->nextLink()
. After successful execution of this function the values of the previousLink
and nextLink
attributes of all the links in the origin and destination lists appropriately reflect the operation. The behavior is undefined unless both first
and last
are non-zero members of the same linked list; first
precedes last
in the list, or first == last
; target
is not a node contained in the closed range [first, last]
; and isWellFormed(first, last)
is true.
◆ unlink()
Unlink the specified node
from the linked list of which it is a member. After successful execution of this function the values of the previousLink
and nextLink
attributes of all the links in the origin and destination lists appropriately reflect the operation Note that this method does not change the value for the nextLink
and previousLink
attributes of node
. The behavior is undefined unless !node->previousLink()
, !node->nextLink()
, or isWellFormed(node->previousLink(), node->nextLink())
are true.
The documentation for this struct was generated from the following file: