31 # include <type_traits> 32 # include <ahFunction.H> 35 using namespace Aleph;
44 template <
typename T>
class Dnode :
public Dlink 74 throw std::underflow_error(
"Dnode is empty");
82 throw std::underflow_error(
"Dnode is empty");
102 throw std::underflow_error(
"Dnode is empty");
110 throw std::underflow_error(
"Dnode is empty");
116 static_assert(std::is_default_constructible<T>::value,
117 "No default constructor for T");
121 Dnode(
const T & item) noexcept(noexcept(T(item))) : data(item)
123 static_assert(std::is_copy_constructible<T>::value,
124 "No copy constructor for T");
128 Dnode(T && item) noexcept(noexcept(std::swap(data, item)))
130 static_assert(std::is_move_constructible<T>::value,
131 "No move constructor for T");
132 std::swap(data, item);
140 std::swap(data, p.data);
145 Dnode(
const Dnode & node) noexcept(std::is_nothrow_copy_assignable<T>::value)
146 :
Dlink(node), data(node.data)
148 static_assert(std::is_copy_constructible<T>::value,
149 "No copy constructor for T");
153 Dnode(
Dnode && node) noexcept(noexcept(std::forward<T>(node.data)))
154 :
Dlink(node), data(
std::forward<T>(node.data))
161 noexcept(std::is_nothrow_copy_assignable<T>::value)
163 static_assert(std::is_copy_assignable<T>::value,
164 "No copy assign for T");
171 noexcept(std::is_nothrow_move_assignable<T>::value)
173 std::swap(data, p.data);
181 const T &
get_data() const noexcept {
return data; }
190 const T &
get_key() const noexcept {
return data; }
197 long offset = (long) &(zero->data);
198 unsigned long addr = (
unsigned long) (&data);
199 return (
Dnode*) (addr - offset);
249 template <
typename T>
Dnode<T> * Dlink::to_dnode() noexcept
251 return static_cast<Dnode<T>*
>(
this);
254 template <
typename T>
const Dnode<T> * Dlink::to_dnode()
const noexcept
256 return static_cast<const Dnode<T>*
>(
this);
259 template <
typename T> T & Dlink::to_data() noexcept
264 template <
typename T>
const T & Dlink::to_data()
const noexcept
static Dnode * data_to_node(T &data) noexcept
Definition: tpl_dnode.H:194
Dnode< T > * remove_last_ne() noexcept
Remove the last node and return its address.
Definition: tpl_dnode.H:87
Dnode & operator=(const Dnode &p) noexcept(std::is_nothrow_copy_assignable< T >::value)
Copy assigment.
Definition: tpl_dnode.H:160
Dlink * remove_prev() noexcept
Definition: dlink.H:413
Dnode & swap(Dnode &p) noexcept(noexcept(std::swap(data, p.data)))
Swap this with p
Definition: tpl_dnode.H:136
Dlink * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
Definition: dlink.H:670
Dnode< T > * remove_first_ne() noexcept
Remove the first node and return its address.
Definition: tpl_dnode.H:93
Dnode(const T &item) noexcept(noexcept(T(item)))
Construct a node with a copy of item
Definition: tpl_dnode.H:121
T & get_key() noexcept
Definition: tpl_dnode.H:187
Dnode(T &&item) noexcept(noexcept(std::swap(data, item)))
Construct a new node with the item moved.
Definition: tpl_dnode.H:128
Dlink * remove_next() noexcept
Definition: dlink.H:434
Dnode< T > * remove_first()
Remove the first node and return its address.
Definition: tpl_dnode.H:107
Dnode< T > * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
Definition: tpl_dnode.H:221
Dnode< T > *& get_next() const noexcept
Return the next node to this
Definition: tpl_dnode.H:53
Dnode< T > *& get_last() const
Get the last node.
Definition: tpl_dnode.H:79
void swap(Dlink *link) noexcept
Definition: dlink.H:82
Dnode< T > * remove_last()
Remove the last node and return its address.
Definition: tpl_dnode.H:99
const T & get_data() const noexcept
Return a modifiable reference to the data contained in the node.
Definition: tpl_dnode.H:181
T & get_data() noexcept
Return a modifiable reference to the data contained in the node.
Definition: tpl_dnode.H:178
const T & get_key() const noexcept
Definition: tpl_dnode.H:190
Dnode< T > * remove_prev() noexcept
Remove the previous node to this; return its address.
Definition: tpl_dnode.H:59
Dnode< T > *& get_prev() const noexcept
Return the previous node to this
Definition: tpl_dnode.H:56
Dlink * get_curr() const
Definition: dlink.H:681
Dnode< T > *& get_first() const
Get the first node.
Definition: tpl_dnode.H:71
bool is_empty() const noexcept
Return true if this (as header node) is empty.
Definition: dlink.H:192
Dnode< T > * remove_next() noexcept
Remove the next node to this; return its address.
Definition: tpl_dnode.H:62
Dnode< T > * get_curr() const
Definition: tpl_dnode.H:231
Dnode * del()
Definition: tpl_dnode.H:244
Definition: tpl_dnode.H:206
typename GT::Node * key_type
The data type.
Definition: tpl_dnode.H:184
Dnode< T > *& get_first_ne() const noexcept
Get the first node.
Definition: tpl_dnode.H:65
Dnode(const Dnode &node) noexcept(std::is_nothrow_copy_assignable< T >::value)
Copy constructor.
Definition: tpl_dnode.H:145
Dnode< T > *& get_last_ne() const noexcept
Get the last node.
Definition: tpl_dnode.H:68
Dnode(Dnode &&node) noexcept(noexcept(std::forward< T >(node.data)))
Move constructor.
Definition: tpl_dnode.H:153
Dlink * del()
Definition: dlink.H:741