Intrusive Containers
Loading...
Searching...
No Matches

Intrusive Double Linked List. More...

#include "Container.h"
Include dependency graph for DListIn.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  DListInNode< R, N, s, n >
 Intrusive Doubly Linked List, Node. More...
 
class  DListInRoot< R, N, s, n >
 Intrusive Doubly Linked List, List. More...
 

Detailed Description

Intrusive Double Linked List.

This file defines a pair of templates (DListInRoot and DListInNode) that implement an intrusive double linked list.

Overview

DListInRoot and DListInNode provide a simple API to allow classes to provide a basic List <-> Node relationship (1 List holding many Nodes) with a doubly linked list. (c.f. ListIn.h, ListInRoot, and ListInNode for singly linked list)

To create this relationship, the class to act as the list derives from the template DListInRoot, and the class to act as the Node from DListInNode, both with a first parameter of the class name of the List class, and a second parameter of the Node class. There is an optional integral 3rd parameter to allow the classes to inherent from these multiple times if you need to represent multiple simultaneous relationships. This inheritance should be public, or you need to add the DListInRoot and DListInNode templates as friends.

At the point of declaration, both classes need to be declared, so you will typically have a forward of the other class before the definition of the class. At the point of usage of members, generally the full definition of both classes is needed to instance the code for the template.

Inside this file, the following types have the following meanings:

R: The "user" type that will be derived from DListInRoot

N: The "user" type that will be derived from DListInNode

n: The integer parameter for the template to allow multiple useage

Root: The particular instance of DListInRoot<R, N, n> being used

Node: The particular instance of DListInNode<R, N, n> being used

node: will have type N*, to be used when walking the list.

Invariant

Given:

  • R& root
  • N& node

DListInRoot:

  • if root.m_first == nullptr
    • root.m_last == nullptr
  • if root.m_first !- nullptr
    • root,m_last != nullptr
    • root.m_first->m_root == &root
    • root.m_first->m_prev == nullptr
    • root.m_last->m_root == &root
    • root.m_last->m_next == nullptr

DListInNode:

  • if node.m_root == nullptr
    • node.m_nest == nullptr
    • node.m_prev == nullptr
  • if node.m_prev == nullptr
    • node.m_root->m_first = &node;
  • if node.m_prev !- nullptr
    • node.m_prev->m_root == node.m_root
    • node.m_orev->m_next == &node
  • if node.m_next == nullptr
    • node.m_root->m_last = &node
  • if node.m_next != nullptr
    • node.m_next->m_root == node.m_root
    • node.m_next->m_prev == &node
See also
DListIn.hpp
ListIn.h