blob: 4a1baf569929c385dc794aaef31f78ee393593fb (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// $Id$
#ifndef ACE_INTRUSIVE_LIST_CPP
#define ACE_INTRUSIVE_LIST_CPP
#include "ace/Intrusive_List.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if !defined (__ACE_INLINE__)
#include "ace/Intrusive_List.inl"
#endif /* __ACE_INLINE__ */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
template <class T>
ACE_Intrusive_List<T>::ACE_Intrusive_List (void)
: head_ (0)
, tail_ (0)
{
}
template<class T>
ACE_Intrusive_List<T>::~ACE_Intrusive_List (void)
{
}
template<class T> void
ACE_Intrusive_List<T>::push_back (T *node)
{
if (this->tail_ == 0)
{
this->tail_ = node;
this->head_ = node;
node->next (0);
node->prev (0);
}
else
{
this->tail_->next (node);
node->prev (this->tail_);
node->next (0);
this->tail_ = node;
}
}
template<class T> void
ACE_Intrusive_List<T>::push_front (T *node)
{
if (this->head_ == 0)
{
this->tail_ = node;
this->head_ = node;
node->next (0);
node->prev (0);
}
else
{
this->head_->prev (node);
node->next (this->head_);
node->prev (0);
this->head_ = node;
}
}
template<class T> T *
ACE_Intrusive_List<T>::pop_front (void)
{
T *node = this->head_;
if (node != 0)
{
this->unsafe_remove (node);
}
return node;
}
template<class T> T *
ACE_Intrusive_List<T>::pop_back (void)
{
T *node = this->tail_;
if (node != 0)
{
this->unsafe_remove (node);
}
return node;
}
template<class T> void
ACE_Intrusive_List<T>::remove (T *node)
{
for (T *i = this->head_; i != 0; i = i->next ())
{
if (node == i)
{
this->unsafe_remove (node);
return;
}
}
}
template<class T> void
ACE_Intrusive_List<T>::unsafe_remove (T *node)
{
if (node->prev () != 0)
node->prev ()->next (node->next ());
else
this->head_ = node->next ();
if (node->next () != 0)
node->next ()->prev (node->prev ());
else
this->tail_ = node->prev ();
node->next (0);
node->prev (0);
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_INTRUSIVE_LIST_CPP */
|