Intrusive Containers
ListIn.h
Go to the documentation of this file.
1 #ifndef LISTIN_H
2 #define LISTIN_H
3 
83 // L a class derived from ListInRoot<L,N,n>
84 // N a class derived from ListInNode<L,N,n>
85 
86 template<class R, class N, int n = 0> class ListInRoot;
87 template<class R, class N, int n = 0> class ListInNode;
88 
102 template<class R, class N, int n> class ListInRoot {
103  friend ListInNode<R, N, n>;
104  friend N;
105  typedef ListInRoot<R, N, n> Root;
106  typedef ListInNode<R, N, n> Node;
107 protected:
108  ListInRoot();
109  ~ListInRoot();
110  void add(N& node);
111  void add(N* node);
112  void addFirst(N& node);
113  void addFirst(N* node);
114  void addLast(N& node);
115  void addLast(N* node);
116  void remove(N& node);
117  void remove(N* node);
118  N* first() const { return first_; }
119 private:
120 #if __cplusplus < 201101L
121  ListInRoot(ListInRoot const&);
122  void operator =(ListInRoot const&);
123 #else
124  ListInRoot(ListInRoot const&) = delete;
125  void operator =(ListInRoot const&) = delete;
126 #endif
127  N* first_;
128 };
129 
143 template<class R, class N, int n> class ListInNode {
144  friend ListInRoot<R, N, n>;
145  friend R;
146  typedef ListInNode<R, N, n> Node;
147  typedef ListInRoot<R, N, n> Root;
148 protected:
149  ListInNode(R& root);
150  ListInNode(R* root = 0);
151  ~ListInNode();
152 
153  void addTo(R& root);
154  void addTo(R* root);
155  void addToFront(R& root);
156  void addToFront(R* root);
157  void addToEnd(R& root);
158  void addToEnd(R* root);
159  void addAfter(N& node);
160  void addAfter(N* node);
161  void remove();
162 
163  R* root() const { return root_; }
164  N* next() const { return next_; }
165 private:
166 #if __cplusplus < 201101L
167  ListInNode(ListInNode const& );
168  void operator =(ListInNode const& );
169 #else
170  ListInNode(ListInNode const& ) = delete;
171  void operator =(ListInNode const& ) = delete;
172 #endif
173  R* root_;
174  N* next_;
175 };
176 
177 #endif
ListInNode(R &root)
Definition: ListIn.hpp:331
N * next() const
Return pointer to next Node on List.
Definition: ListIn.h:164
void addToFront(R &root)
Definition: ListIn.hpp:204
void addTo(R &root)
Definition: ListIn.hpp:283
void addLast(N &node)
Definition: ListIn.hpp:142
void addAfter(N &node)
Definition: ListIn.hpp:253
Definition: ListIn.h:86
R * root() const
Return pointer to List we are on.
Definition: ListIn.h:163
N * first() const
Return pointer to first Node on list.
Definition: ListIn.h:118
ListInRoot()
Definition: ListIn.hpp:303
Definition: ListIn.h:87
~ListInRoot()
Definition: ListIn.hpp:311
~ListInNode()
Definition: ListIn.hpp:343
void add(N &node)
Definition: ListIn.hpp:182
void addFirst(N &node)
Definition: ListIn.hpp:115
void addToEnd(R &root)
Definition: ListIn.hpp:227