[#BloombergLP-bslalg-BidirectionalLinkListUtil]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslalg.adoc[bslalg]::BidirectionalLinkListUtil
:relfileprefix: ../../
:mrdocs:

This `struct` provides a namespace for utility functions that manipulate linked lists based on `bslalg&colon;&colon;BidirectionalLink` nodes, including insertion, removal, and _splicing_&period;

== Synopsis

Declared in `&lt;bslalg&lowbar;bidirectionallinklistutil&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct BidirectionalLinkListUtil;
----

== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslalg/BidirectionalLinkListUtil/insertLinkAfterTarget.adoc[`insertLinkAfterTarget`] 
| Insert the specified `newNode` after the specified `target` node in the linked list that contains `target`&period; If the node following `target` is 0, then set the `nextLink` attribute of `newNode` to 0&period; 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&period; The behavior is undefined unless `0 !&equals; newNode` and `0 !&equals; target`&period; The behavior is also undefined unless `0 &equals;&equals; target&hyphen;&gt;nextLink()` is true or `isWellFormed(target, target&hyphen;&gt;nextLink())` are true&period;
| xref:BloombergLP/bslalg/BidirectionalLinkListUtil/insertLinkBeforeTarget.adoc[`insertLinkBeforeTarget`] 
| Insert the specified `newNode` before the specified `target` node in the linked list that contains `target`&period; If `target` is 0, then the value of the attributes `nextLink` and `previousLink` of `newNode` is set to 0&period; 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&period; The behavior is undefined unless `0 &equals;&equals; target&hyphen;&gt;previousLink()` is true or `isWellFormed(target&hyphen;&gt;previousLink(), target)` is true&period;
| xref:BloombergLP/bslalg/BidirectionalLinkListUtil/isWellFormed.adoc[`isWellFormed`] 
| Return true if the bidirectional list starting from the specified `head`, and ending with the specified `tail` is well formed&period; A bidirectional list is well formed if `tail &equals;&equals; 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)&colon;
| xref:BloombergLP/bslalg/BidirectionalLinkListUtil/spliceListBeforeTarget.adoc[`spliceListBeforeTarget`] 
| Unlink and move (splice) the elements of a doubly&hyphen;linked list included in the closed range `&lsqb;first, last&rsqb;` out of their original list and into another doubly&hyphen;linked list before the specified `target` node&period; If `target` is 0, then the elements are extracted and form a new list such that `0 &equals;&equals; first&hyphen;&gt;previousLink()` and `0 &equals;&equals; last&hyphen;&gt;nextLink()`&period; 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&period; The behavior is undefined unless both `first` and `last` are non&hyphen;zero members of the same linked list&semi; `first` precedes `last` in the list, or `first &equals;&equals; last`&semi; `target` is not a node contained in the closed range `&lsqb;first, last&rsqb;`&semi; and `isWellFormed(first, last)` is true&period;
| xref:BloombergLP/bslalg/BidirectionalLinkListUtil/unlink.adoc[`unlink`] 
| Unlink the specified `node` from the linked list of which it is a member&period; 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`&period; The behavior is undefined unless `!node&hyphen;&gt;previousLink()`, `!node&hyphen;&gt;nextLink()`, or `isWellFormed(node&hyphen;&gt;previousLink(), node&hyphen;&gt;nextLink())` are true&period;
|===



[.small]#Created with https://www.mrdocs.com[MrDocs]#
