Intrusive Containers
|
Intrusive Sorted Double Linked List. More...
#include "ListIn.h"
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... | |
Intrusive Sorted Double Linked List.
This file defines a pair of templates (SortListInRoot and SortListInNode) that implement an intrusive double linked list.
MIT License:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.
Given:
New
From DListIn.h
This file defines a pair of templates (SortListInRoot and SortListInNode) that implement an intrusive double linked list.
MIT License:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.
Given:
New:
From ListIn.h:
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