BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslalg::BidirectionalLinkListUtil Struct Reference

#include <bslalg_bidirectionallinklistutil.h>

Static Public Member Functions

static void insertLinkBeforeTarget (BidirectionalLink *newNode, BidirectionalLink *target)
 
static void insertLinkAfterTarget (BidirectionalLink *newNode, BidirectionalLink *target)
 
static bool isWellFormed (BidirectionalLink *head, BidirectionalLink *tail)
 
static void spliceListBeforeTarget (BidirectionalLink *first, BidirectionalLink *last, BidirectionalLink *target)
 
static void unlink (BidirectionalLink *node)
 

Detailed Description

This struct provides a namespace for utility functions that manipulate linked lists based on bslalg::BidirectionalLink nodes, including insertion, removal, and splicing.

Member Function Documentation

◆ insertLinkAfterTarget()

static void bslalg::BidirectionalLinkListUtil::insertLinkAfterTarget ( BidirectionalLink newNode,
BidirectionalLink target 
)
static

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()

static void bslalg::BidirectionalLinkListUtil::insertLinkBeforeTarget ( BidirectionalLink newNode,
BidirectionalLink target 
)
static

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()

static bool bslalg::BidirectionalLinkListUtil::isWellFormed ( BidirectionalLink head,
BidirectionalLink tail 
)
static

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):

  1. h and t are valid addresses.
  2. h->nextLink()->previousLink() == h is true.
  3. !h->previousLink() || h->previousLink()->nextLink() == h is true.
  4. t->previousLink()->nextLink() == t is true.
  5. !t->nextLink() || t->nextLink()->previousLink() == t is true.
  6. 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()

static void bslalg::BidirectionalLinkListUtil::spliceListBeforeTarget ( BidirectionalLink first,
BidirectionalLink last,
BidirectionalLink target 
)
static

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()

static void bslalg::BidirectionalLinkListUtil::unlink ( BidirectionalLink node)
static

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: