Intrusive Containers
DListIn.h
Go to the documentation of this file.
1 #ifndef DListIn_H
2 #define DListIn_H
3 
97 template <class R,class N, int n = 0> class DListInNode;
98 template <class R, class N, int n = 0> class DListInRoot;
99 
113 template <class R, class N, int n> class DListInRoot {
114  friend class DListInNode<R, N, n>;
115  typedef class DListInRoot<R, N, n> Root;
116  typedef class DListInNode<R, N, n> Node;
117 public:
118  DListInRoot();
119  ~DListInRoot();
120 
121  void add(N& node);
122  void add(N* node);
123  void addFirst(N& node);
124  void addFirst(N* node);
125  void addLast(N& node);
126  void addLast(N* node);
127  void remove(N& node);
128  void remove(N* node);
129 
130  N* first() const {return first_;}
131  N* last() const { return last_; }
132 
133 private:
134 #if __cplusplus < 201101L
135  DListInRoot(DListInRoot const&);
136  void operator =(DListInRoot const&);
137 #else
138  DListInRoot(DListInRoot const&) = delete;
139  void operator =(DListInRoot const&) = delete;
140 #endif
141  N* first_;
142  N* last_;
143 };
144 
158 template <class R, class N, int n> class DListInNode {
159  friend class DListInRoot<R, N, n>;
160  typedef class DListInRoot<R, N, n> Root;
161  typedef class DListInNode<R, N, n> Node;
162 public:
163  DListInNode(R* root=0);
164  DListInNode(R&);
165  ~DListInNode();
166 
167  void addTo(R& root);
168  void addTo(R* root);
169  void addToFront(R& root);
170  void addToFront(R* root);
171  void addToEnd(R& root);
172  void addToEnd(R* root);
173  void addAfter(N& node);
174  void addAfter(N* node);
175  void remove();
176 
177  R* root() const { return root_; }
178  N* next() const { return next_; }
179  N* prev() const { return prev_; }
180 
181 private:
182 #if __cplusplus < 201101L
183  DListInNode(DListInNode const&);
184  void operator =(DListInNode const&);
185 #else
186  DListInNode(DListInNode const&) = delete;
187  void operator =(DListInNode const&) = delete;
188 #endif
189  R* root_;
190  N* prev_;
191  N* next_;
192 };
193 #endif
~DListInNode()
Definition: DListIn.hpp:348
void addTo(R &root)
Definition: DListIn.hpp:283
N * first() const
Definition: DListIn.h:130
DListInRoot()
Definition: DListIn.hpp:303
N * prev() const
Return pointer to previous node on list.
Definition: DListIn.h:179
DListInNode(R *root=0)
Definition: DListIn.hpp:322
void addFirst(N &node)
Definition: DListIn.hpp:104
Definition: DListIn.h:98
void add(N &node)
Definition: DListIn.hpp:176
void addLast(N &node)
Definition: DListIn.hpp:137
void addAfter(N &node)
Definition: DListIn.hpp:247
R * root() const
Return pointer to list we are on.
Definition: DListIn.h:177
N * last() const
Definition: DListIn.h:131
void addToEnd(R &root)
Definition: DListIn.hpp:221
~DListInRoot()
Definition: DListIn.hpp:313
Definition: DListIn.h:97
N * next() const
Return pointer to next node on list.
Definition: DListIn.h:178
void addToFront(R &root)
Definition: DListIn.hpp:198