BloombergLP::bslalg::BidirectionalLinkListUtil::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):

Synopsis

Declared in <bslalg_bidirectionallinklistutil.h>

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

Description

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