BloombergLP::bslalg::BidirectionalLinkListUtil::isWellFormed

Return true if the list from head to tail is well formed.

Synopsis

Declared in <bslalg_bidirectionallinklistutil.h>

static
bool
isWellFormed(
    BidirectionalLink* head,
    BidirectionalLink* tail);

Description

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)].

Return Value

true if the list from head to tail is well formed

Parameters

NameDescription
headfirst node of the list to test
taillast node of the list to test