Intrusive Containers
Loading...
Searching...
No Matches
ListIn.hpp
Go to the documentation of this file.
1#ifndef LISTIN_HPP
2#define LISTIN_HPP
3
4/**
5@file ListIn.hpp
6@brief Intrusive Singly Linked List, Implementation.
7
8This file defines a pair of templates (ListInRoot and ListInNode) that
9implement an intrusive singly linked list.
10
11@copyright (c) 2014-2024 Richard Damon
12@parblock
13MIT License:
14
15Permission is hereby granted, free of charge, to any person obtaining a copy
16of this software and associated documentation files (the "Software"), to deal
17in the Software without restriction, including without limitation the rights
18to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19copies of the Software, and to permit persons to whom the Software is
20furnished to do so, subject to the following conditions:
21
22The above copyright notice and this permission notice shall be included in
23all copies or substantial portions of the Software.
24
25THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31THE SOFTWARE.
32@endparblock
33
34@see ListIn.h
35@see DListIn.h
36@ingroup IntrusiveContainers
37*/
38
39#include "ListIn.h"
40
41/******************************************************************************************
42Implementation
43
44Note that when we need to convert a List or Node pointer/reference to a ListInRoot/ListInNode
45pointer/reference we need to do an explicit static_cast, to avoid ambiquity in the case of
46classes deriving from multiple versions of ListInRoot/ListInNode
47*/
48
49/**
50 *
51 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
52 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
53 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
54 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
55 * @return True if check passes
56 */
57
58template <class R, class N, ContainerThreadSafety s, int n>
60 bool flag = true;
61 if (first()) {
62 N* node = last();
63 flag &= (node != nullptr); // if have first, must have last
64 if (!flag) return flag;
65 Node* mynode = node;
66 flag &= (mynode->root() == this); // last must point to us
67 flag &= (mynode->next() == nullptr); // last must not point to more
68 node = first();
69 mynode = node;
70 flag &= (mynode->root() == this); // first must point to us
71 while(flag && mynode){
72 flag &= mynode->check(); // check all the nodes on the list
73 mynode = mynode->next();
74 }
75 } else {
76 flag &= (last() == nullptr); // if no first, then no last either.
77 }
78 return flag;
79}
80
81/**
82 *
83 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
84 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
85 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
86 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
87 * @return True if check passes
88 */
89template <class R, class N, ContainerThreadSafety s, int n>
91 bool flag = true;
92 if (root()) {
93 Node* mynode = next();
94 if (mynode) {
95 flag &= mynode->root() == root();
96 } else {
97 flag &= (static_cast<Root*>(root())->last() == this); // last in chain, so verify last
98 }
99 } else {
100 flag &= next() == nullptr; // no root, so we must be unattached
101 }
102 return flag;
103}
104
105/**
106 * Remove node from whatever list it is on, if it is on a list.
107 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
108 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
109 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
110 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
111*/
112template <class R, class N, ContainerThreadSafety s, int n>
114 unsigned save = readLock(true);
115 R* root = m_root;
116 if (m_root) {
117 Root* mylist = static_cast<Root*>(m_root);
118 // We are on a list, are we the first node?
119 if (mylist->m_first == this) {
120 unsigned save1 = writeLock(true);
121 R* root1 = m_root;
122 // Yes, point root to next node in list (if any), and disconnect us.
123 mylist->m_first = m_next;
124 if(mylist->m_last == this) mylist->m_last = nullptr;
125 m_next = nullptr;
126 setRoot(nullptr);
127 root1->Root::writeUnlock(save1);
128 } else {
129 // We aren't the first, so find the node before us.
130 N* node = mylist->m_first;
131
132 while (node != nullptr) {
133 Node* mynode = node;
134 N* nextNode = mynode->m_next;
135 if (nextNode == this) {
136 unsigned save1 = writeLock(true);
137 R* root1 = m_root;
138 // Found our predecessor, unlink
139 mynode->m_next = m_next;
140 if(m_next == nullptr) {
141 mylist->m_last = node;
142 }
143 m_next = nullptr;
144 setRoot(nullptr);
145 root1->Root::writeUnlock(save1);
146 break;
147 }
148 node = mynode->m_next;
149 // we could assert node here, as we should be able to find ourselves on the list
150 }
151 }
152 }
153 root->Root::readUnlock(save);
154}
155
156
157/**
158Remove Node from List
159 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
160 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
161 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
162 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
163 * @param node node to be removed.
164 * If node is not on this list, nothing will be done.
165*/
166template <class R, class N, ContainerThreadSafety s, int n_>
168 Node& mynode = node;
169 if (mynode.m_root == this) {
170 // Only remove if node is on this list.
171 mynode.remove();
172 }
173}
174
175
176/**
177Remove Node from List
178 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
179 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
180 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
181 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
182 * @param node Pointer to node to be removed.
183 * If node is null, operation will be ignored.
184 * If node is not on this list, nothing will be done.
185*/
186template <class R, class N, ContainerThreadSafety s, int n_>
188 if (node != nullptr) remove(*node);
189}
190
191/**
192Add node to front of our list.
193 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
194 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
195 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
196 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
197 * @param node The node to add to the list
198 * If node is currently on a list (even us) it is removed before being added to the list
199 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
200*/
201template<class R, class N, ContainerThreadSafety s, int n_>
202inline void ListInRoot<R, N, s, n_>::addFirst(N& node, bool upgrade) {
203 Node& mynode = node;
204
205 if (mynode.m_root != nullptr) mynode.remove();
206 unsigned save = writeLock(upgrade);
207 mynode.setRoot(static_cast<R*>(this));
208 mynode.m_next = m_first;
209 m_first = &node;
210 writeUnlock(save);
211}
212
213/**
214Add node to front of our list.
215 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
216 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
217 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
218 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
219 * @param node The node to add to the list
220 * If node is currently on a list (even us) it is removed before being added to the list
221 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
222*/
223template<class R, class N, ContainerThreadSafety s, int n_>
224inline void ListInRoot<R, N, s, n_>::addFirst(N* node, bool upgrade) {
225 if (node != nullptr) addFirst(*node, upgrade);
226}
227
228/**
229Add node to end of our list.
230 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
231 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
232 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
233 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided
234 * @param node The node to add to the list
235 * If node is currently on a list (even us) it is removed before being added to the list
236 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
237*/
238
239template<class R, class N, ContainerThreadSafety s, int n_>
240inline void ListInRoot<R, N, s, n_>::addLast(N& node, bool upgrade) {
241 Node& mynode = node;
242
243 unsigned save;
244 // if upgrading we already have the read lock
245 if (!upgrade) save = readLock(false);
246 if (mynode.m_root != nullptr) mynode.remove();
247
248 unsigned save1 = writeLock(upgrade);
249 if (m_last == nullptr) {
250 // List is empty
251 m_first = &node;
252 } else {
253 static_cast<Node*>(m_last)->m_next = &node;
254 }
255 m_last = &node;
256 mynode.setRoot(static_cast<R*>(this));
257 mynode.m_next = nullptr;
258 writeUnlock(save1);
259 if (!upgrade) readUnlock(save);
260}
261
262/**
263 * Add node to end of our list.
264 * Note that this operation is O(n) on list current size. See DListInRoot to make this O(1).
265 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
266 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
267 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
268 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
269 * @param node The node to add to the list
270 * If node is currently on a list (even us) it is removed before being added to the list
271 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
272*/
273
274template<class R, class N, ContainerThreadSafety s, int n_>
275inline void ListInRoot<R, N, s, n_>::addLast(N* node, bool upgrade) {
276 if (node != nullptr) addLast(*node, upgrade);
277}
278
279
280
281/**
282 * Add node to our list, at "natural" point.
283 * Note that this is the front for singly linked lists and the end for doubly linked list.
284 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
285 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
286 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
287 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
288 * @param node The node to add to the list
289 * If node is currently on a list (even us) it is removed before being added to the list
290 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
291*/
292template<class R, class N, ContainerThreadSafety s, int n_>
293inline void ListInRoot<R, N, s, n_>::add(N& node, bool upgrade) {
294 addFirst(node, upgrade);
295}
296
297
298/**
299Add node to our list, at "natural" point.
300Note that this is the front for singly linked lists and the end for doubly linked lists.
301
302 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
303 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
304 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
305 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
306 * @param node The node to add to the list
307 * If node is nulR, Nothing is done.
308 * If node is currently on a list (even us) it is removed before being added to the list
309 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
310*/
311template<class R, class N, ContainerThreadSafety s, int n_>
312inline void ListInRoot<R, N, s, n_>::add(N* node, bool upgrade) {
313 if (node != nullptr) add(*node, upgrade);
314}
315
316/**
317Add ourselfs to the front of a list
318
319 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
320 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
321 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
322 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
323 * @param myRoot List to add to.
324 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
325*/
326template<class R, class N, ContainerThreadSafety s, int n>
327inline void ListInNode<R, N, s, n>::addToFront(R& myRoot, bool upgrade) {
328 static_cast<Root&>(myRoot).addFirst(*static_cast<N*>(this), upgrade);
329}
330
331/**
332Add ourselfs to the front of a list
333
334 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
335 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
336 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
337 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
338 * @param myRoot List to add to.
339 * If NULL, just remove from all lists.
340 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
341*/
342template<class R, class N, ContainerThreadSafety s, int n>
343inline void ListInNode<R, N, s, n>::addToFront(R* myRoot, bool upgrade) {
344 if (myRoot) {
345 static_cast<Root*>(myRoot)->addFirst(*static_cast<N*>(this), upgrade);
346 } else {
347 remove();
348 }
349}
350
351/**
352Add ourselfs to the end of a list
353
354 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
355 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
356 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
357 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
358 * @param myRoot List to add to.
359 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
360*/
361template<class R, class N, ContainerThreadSafety s, int n>
362inline void ListInNode<R, N, s, n>::addToEnd(R& myRoot, bool upgrade) {
363 static_cast<Root&>(myRoot).addLast(*static_cast<N*>(this), upgrade);
364}
365
366
367/**
368 * Add ourselves to the End of a list
369 *
370 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
371 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
372 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
373 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
374 * @param myRoot List to add to.
375 * If NULL, just remove from all lists.
376 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
377 */
378template<class R, class N, ContainerThreadSafety s, int n>
379inline void ListInNode<R, N, s, n>::addToEnd(R* myRoot, bool upgrade) {
380 if (myRoot) {
381 static_cast<Root*>(myRoot)->addLast(*static_cast<N*>(this), upgrade);
382 } else {
383 remove();
384 }
385}
386
387/**
388Add ourself to a list after another node.
389
390 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
391 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
392 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
393 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
394 * @param node The node to add ourself after.
395 * If node is not on a list, do nothing.
396 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
397*/
398
399template<class R, class N, ContainerThreadSafety s, int n>
400inline void ListInNode<R, N, s, n>::addAfter(N& node, bool upgrade) {
401 Node &mynode = node;
402 N* me = static_cast<N*>(this);
403 if (mynode.m_root && &node != me) {
404 remove();
405 unsigned save = mynode.writeLock(upgrade);
406 setRoot(mynode.m_root);
407 m_next = mynode.m_next;
408 mynode.m_next = me;
409 mynode.writeUnlock(save);
410 }
411}
412
413/**
414Add ourself to a list after another node.
415
416 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
417 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
418 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
419 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
420 * @param node The node to add ourself after.
421 * If Node is NULL, or not on a list, do nothing.
422 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
423*/
424
425template<class R, class N, ContainerThreadSafety s, int n>
426inline void ListInNode<R, N, s, n>::addAfter(N* node, bool upgrade) {
427 if (node != nullptr) {
428 addAfter(*node, upgrade);
429 }
430}
431
432/**
433Add ourself to a list at "natural" postion.
434Note that this is the front for singly linked lists, and the end for doubly linked lists.
435
436 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
437 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
438 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
439 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
440 * @param myRoot List to add to.
441 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
442*/
443template<class R, class N, ContainerThreadSafety s, int n>
444void ListInNode<R, N, s, n>::addTo(R& myRoot, bool upgrade) {
445 addToFront(myRoot, upgrade);
446}
447
448/**
449Add ourself to a list at "natural" postion.
450Note that this is the front for singly linked lists, and the end for doubly linked lists.
451
452 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
453 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
454 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
455 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
456 * @param myRoot List to add to.
457 * @param upgrade Set True if caller has an upgradable Read Lock (Used by SortDListInNode)
458*/
459template<class R, class N, ContainerThreadSafety s, int n>
460void ListInNode<R, N, s, n>::addTo(R* myRoot, bool upgrade) {
461 addToFront(myRoot, upgrade);
462}
463
464
465/**
466Constructor.
467
468Starts us as an empty list.
469 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
470 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
471 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
472 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
473*/
474template <class R, class N, ContainerThreadSafety s, int n>
476m_first(nullptr) {}
477
478/**
479Destructor.
480
481Removes all nodes attached to us.
482 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
483 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
484 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
485 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
486*/
487template <class R, class N, ContainerThreadSafety s, int n>
489 while (m_first) remove(m_first);
490}
491
492/**
493Constructor.
494
495 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
496 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
497 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
498 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
499@param myRoot Pointer to list for node to be added to (if not NULL).
500*/
501template <class R, class N, ContainerThreadSafety s, int n>
503ContainerNode<s>(nullptr),
504m_root(nullptr),
505m_next(nullptr) {
506 if (myRoot) addTo(myRoot);
507}
508
509/**
510Constructor.
511
512 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
513 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
514 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
515 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
516@param myRoot list we are to be added to.
517*/
518template <class R, class N, ContainerThreadSafety s, int n>
520m_root(0),
521m_next(0)
522{
523 addTo(myRoot);
524}
525
526/**
527Destructor.
528
529Remove us from we are on, if any.
530 * @tparam R The class that will be the owner of the Tree. Must derive from TreeInRoot<R, N, K, n>
531 * @tparam N The class that will be the nodes of the Tree. Must derive from TreeInNode<R, N, K, n>
532 * @tparam s The ContainerThreadSafety value to define the thread safety model of the Container
533 * @tparam n A numerical parameter to allow a give List/Node combination to have multiple list-node relationships. Defaults to 0 if not provided.
534*/
535template <class R, class N, ContainerThreadSafety s, int n>
539#endif
Intrusive Singly Linked List.
Base Container Node Class.
Definition Container.h:255
Intrusive Singly Linked List, Node.
Definition ListIn.h:194
void setRoot(R *root)
Definition ListIn.h:216
void writeUnlock(unsigned save) const
Definition ListIn.h:222
N * m_next
Pointer to next Node in list.
Definition ListIn.h:230
void addTo(R &myRoot, bool upgrade=false)
Add ourself to a list at "natural" postion.
Definition ListIn.hpp:444
void addAfter(N &myNode, bool upgrade=false)
Add ourself to a list after another node.
Definition ListIn.hpp:400
ListInNode(R &myRoot)
Constructor.
Definition ListIn.hpp:519
void addToEnd(R &myRoot, bool upgrade=false)
Add ourselfs to the end of a list.
Definition ListIn.hpp:362
R * root() const
Return pointer to List we are on.
Definition ListIn.h:214
R * m_root
Pointer to list we are on.
Definition ListIn.h:229
void addToFront(R &myRoot, bool upgrade=false)
Add ourselfs to the front of a list.
Definition ListIn.hpp:327
void remove()
Remove node from whatever list it is on, if it is on a list.
Definition ListIn.hpp:113
bool check() const override
Definition ListIn.hpp:90
N * next() const
Return pointer to next Node on List.
Definition ListIn.h:215
~ListInNode()
Destructor.
Definition ListIn.hpp:536
unsigned writeLock(bool upgrade) const
Definition ListIn.h:221
Intrusive Singly Linked List, List.
Definition ListIn.h:131
void remove(N &node)
Remove Node from List.
Definition ListIn.hpp:167
void addFirst(N &node, bool upgrade=false)
Add node to front of our list.
Definition ListIn.hpp:202
void add(N &node, bool upgrade=false)
Add node to our list, at "natural" point.
Definition ListIn.hpp:293
N * last() const
Return pointer to last Node on list.
Definition ListIn.h:149
ListInRoot()
Constructor.
Definition ListIn.hpp:475
N * m_first
Pointer to first Node on list.
Definition ListIn.h:161
bool check() const override
Definition ListIn.hpp:59
void addLast(N &node, bool upgrade=false)
Add node to end of our list.
Definition ListIn.hpp:240
~ListInRoot()
Destructor.
Definition ListIn.hpp:488
N * m_last
Pointer to last Node on list.
Definition ListIn.h:162