Intrusive Containers
Loading...
Searching...
No Matches
SortListIn.h File Reference

Intrusive Sorted Double Linked List. More...

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

Go to the source code of this file.

Classes

class  SortListInNode< R, N, s, n >
 Intrusive Doubly Linked List, Node. More...
 
class  SortListInRoot< R, N, s, n >
 Intrusive Doubly Linked List, List. More...
 

Detailed Description

Intrusive Sorted Double Linked List.

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

Warning
The Sorted Lists are new additions and not fully tested
Overview

SortDListInRoot and SortDListInNode provide a simple API to allow classes to provide a basic List <-> Node relationship (1 List holding many Nodes) with a sorted doubly linked list. (c.f. DListIn.h, DListInRoot, and DListInNode for an unsorted list)

To create this relationship, the class to act as the list derives from the template SortListInRoot, and the class to act as the Node from SortListInNode, both with a first parameter of the class name of the List class, and a second parameter of the Node class. There is a third parameter, which can specify a thread safety option, defaulting to no thread safety provide by the library. Use of any other requires the Containers.h/hpp be configured to understand the operating system that it is being run under. There is an optional integral 4th 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 SortListInRoot and SortListInNode templates as friends as they need to convert pointers between the two classes.

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 SortListInRoot

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

s: The thread safety standard selected.

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

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

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

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

Invariant

Given:

  • R& root
  • N& node

New

SortDListInNode:

  • if node.m_prev != nullptr
    • node.m_root->compare(node, *node.m_prev) <= 0
    • node.m_root->compare(*node.m_prev, node) >a= 0
  • if node.m_next != nullptr
    • node.m_root->compare(node, *node.m_next) >= 0
    • node.m_root->compare(*node.m_next, node) <= 0

From DListIn.h

DListInRoot:

  • if root.m_first == nullptr
    • root.m_last == nullptr
  • if root.m_first !- nullptr
    • root,m_last != nullotr
    • 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

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

Warning
The Sorted Lists are new additions and not fully tested
Overview

SortListInRoot and SortListInNode provide a simple API to allow classes to provide a basic List <-> Node relationship (1 List holding many Nodes) with a sorted linked list. (c.f. ListIn.h, ListInRoot, and ListInNode for an unsorted list)

To create this relationship, the class to act as the list derives from the template SortListInRoot, and the class to act as the Node from SortListInNode, both with a first parameter of the class name of the List class, and a second parameter of the Node class. There is a third parameter, which can specify a thread safety option, defaulting to no thread safety provide by the library. Use of any other requires the Containers.h/hpp be configured to understand the operating system that it is being run under. There is an optional integral 4th 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 SortListInRoot and SortListInNode templates as friends as they need to convert pointers between the two classes.

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 SortListInRoot

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

s: The thread safety standard selected.

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

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

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

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

Invariant

Given:

  • R& root
  • N& node

New:

SortListInNode:

  • if node.m_next != nullptr
    • node.m_root->compare(node, *node.m_next) >= 0
    • node.m_root->compare(*node.m_next, node) <= 0

From ListIn.h:

ListInRoot:

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

ListInNode:

  • if node.m_root == nullptr
    • node.m_nest == nullptr
  • 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 != node.m_root->m_first

Last Criteria is closet expression to the fact that root.m_first points to a node that other node points to as its m_next

See also
DListIn.hpp
ListIn.h