Om
list.hpp
Go to the documentation of this file.
1 
15 #ifndef Om_List_
16 
17  #define Om_List_ \
18  Om::List
19 
20  #ifndef Om_Macro_Precompilation_
21 
22  #include "boost/array.hpp"
23 
24  #endif
25 
26 namespace Om {
27 
28  // MARK: - Om::List
29 
34  template <typename ThisValue>
35  class List {
36 
37  public: // MARK: public (static)
38 
39  enum NodeIndex {
42  };
43 
44  class Node;
45 
46  public: // MARK: public (non-static)
47 
48  List();
49 
50  void Clear();
51 
57 
62  Node const * GetNode(NodeIndex const) const;
63 
64  bool IsEmpty() const;
65 
70  void LinkNode(
71  NodeIndex const,
72  Node &
73  );
74 
79  void RelinkNode(
80  NodeIndex const,
81  Node &
82  );
83 
84  void Swap(List &);
85 
91 
92  private: // MARK: private (static)
93 
94  typedef boost::array<
95  Node *,
96  2
98 
99  private: // MARK: private (non-static)
100 
106 
107  };
108 
109  // MARK: - Om::List::Node
110 
115  template <typename ThisValue>
116  class List<ThisValue>::Node {
117 
118  friend class List<ThisValue>;
119 
120  public: // MARK: public (non-static)
121 
122  Node();
123 
129 
134  Node const * GetNode(NodeIndex const) const;
135 
140  ThisValue & GetValue();
141 
146  ThisValue const & GetValue() const;
147 
148  private: // MARK: private (non-static)
149 
155 
156  ThisValue thisValue;
157 
158  };
159 
160 }
161 
162  #include "om/list.cpp"
163 
164 #endif
A List node.
Definition: list.hpp:116
Node * GetNode(NodeIndex const)
Gets the prior or next Node.
ThisValue & GetValue()
Gets a reference to the stored value.
ThisValue thisValue
Definition: list.hpp:156
Node const * GetNode(NodeIndex const) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
NodeArray thisNodeArray
The prior and next Node; cannot both be null.
Definition: list.hpp:154
ThisValue const & GetValue() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
A doubly-linked list in which nodes are unowned.
Definition: list.hpp:35
bool IsEmpty() const
Node * UnlinkNode(NodeIndex const)
Unlinks the Node at the specified end and returns it.
NodeArray thisNodeArray
The first and last Node; both are null if the list is empty.
Definition: list.hpp:105
boost::array< Node *, 2 > NodeArray
Definition: list.hpp:97
void Clear()
NodeIndex
Definition: list.hpp:39
@ theFrontNodeIndex
Definition: list.hpp:40
@ theBackNodeIndex
Definition: list.hpp:41
void RelinkNode(NodeIndex const, Node &)
Relinks the Node to the specified end.
Node const * GetNode(NodeIndex const) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Node * GetNode(NodeIndex const)
Gets the first or last Node.
void LinkNode(NodeIndex const, Node &)
Links the Node to the specified end.
void Swap(List &)
Om source file.
The Om library.
Definition: code_point.hpp:26