forked from msinilo/rdestl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintrusive_slist.cpp
More file actions
37 lines (33 loc) · 815 Bytes
/
intrusive_slist.cpp
File metadata and controls
37 lines (33 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "intrusive_slist.h"
namespace rde
{
intrusive_slist_base::intrusive_slist_base()
{
/**/
}
intrusive_slist_base::size_type intrusive_slist_base::size() const
{
size_type numNodes(0);
const intrusive_slist_node* iter = &m_root;
do
{
iter = iter->next;
++numNodes;
}
while (iter != &m_root);
return numNodes - 1;
}
void intrusive_slist_base::link_after(intrusive_slist_node* node, intrusive_slist_node* prevNode)
{
RDE_ASSERT(!node->in_list());
node->next = prevNode->next;
prevNode->next = node;
}
void intrusive_slist_base::unlink_after(intrusive_slist_node* node)
{
RDE_ASSERT(node->in_list());
intrusive_slist_node* thisNode = node->next;
node->next = thisNode->next;
thisNode->next = thisNode;
}
} // namespace rde