49# include <type_traits>
148# if defined(__GNUC__) || defined(__clang__)
150# elif defined(_MSC_VER)
156# define INIT_CLASS_BINNODE(Name, height, Control_Data) \
157 template <typename Key> \
158 class Name : public Control_Data \
161 static const size_t MaxHeight = height; \
162 static Name * const NullPtr; \
163 typedef Key key_type; \
164 typedef Key Key_Type; \
174 Key & get_key() noexcept { return key; } \
175 const Key & get_key() const noexcept { return key; } \
176 Name *& getL() noexcept { return lLink; } \
177 Name *& getR() noexcept { return rLink; } \
178 const Name * getL() const noexcept { return lLink; } \
179 const Name * getR() const noexcept { return rLink; } \
181 : key(k), lLink(NullPtr), rLink(NullPtr) \
183 static_assert(std::is_copy_constructible<Key>::value, \
184 "No copy constructor for Key"); \
186 Name(Key && k) noexcept \
187 : key(std::move(k)), lLink(NullPtr), rLink(NullPtr) \
189 static_assert(std::is_move_constructible<Key>::value, \
190 "No move constructor for Key"); \
192 Name(const Control_Data & control_data, const Key & k) \
193 : Control_Data(control_data), \
194 key(k), lLink(NullPtr), rLink(NullPtr) \
198 Name(const Name & node) \
199 : Control_Data(node), \
200 key(node.key), lLink(NullPtr), rLink(NullPtr) \
205 : Control_Data(std::move(static_cast<Control_Data &>(node))), \
206 key(std::move(node.key)), lLink(NullPtr), rLink(NullPtr) \
210 Name(const Control_Data & control_data) noexcept : \
211 Control_Data(control_data), \
212 lLink(NullPtr), rLink(NullPtr) \
217 : lLink(NullPtr), rLink(NullPtr) \
219 static_assert(std::is_default_constructible<Key>::value, \
220 "No default constructor for Key"); \
222 void reset() noexcept \
224 Control_Data::reset(); \
225 rLink = lLink = NullPtr; \
227 static Name * key_to_node(Key & __key) noexcept \
229 const size_t offset = __builtin_offsetof(Name, key); \
230 char * addr = reinterpret_cast<char *>(&__key); \
231 return reinterpret_cast<Name *>(addr - offset); \
258# define DECLARE_BINNODE(Name, height, Control_Data) \
259 INIT_CLASS_BINNODE(Name, height, Control_Data) \
261 template <typename Key> Name<Key> * const Name<Key>::NullPtr = nullptr; \
262 INIT_CLASS_BINNODE(Name##Vtl, height, Control_Data) \
263 virtual ~Name##Vtl() { } \
265 template <typename Key> Name##Vtl<Key> * \
266 const Name##Vtl<Key>::NullPtr = nullptr
298# define DECLARE_BINNODE_SENTINEL(Name, height, Control_Data) \
299 INIT_CLASS_BINNODE(Name, height, Control_Data) \
300 Name(SentinelCtor) : \
301 Control_Data(sentinelCtor), lLink(NullPtr), rLink(NullPtr) {} \
302 static Name sentinel_node; \
304 template <typename Key> \
305 Name<Key> Name<Key>::sentinel_node(sentinelCtor); \
306 template <typename Key> \
307 Name<Key> * const Name<Key>::NullPtr = &Name<Key>::sentinel_node; \
308 INIT_CLASS_BINNODE(Name##Vtl, height, Control_Data) \
309 virtual ~Name##Vtl() { } \
311 Name##Vtl(SentinelCtor) : \
312 Control_Data(sentinelCtor), lLink(NullPtr), rLink(NullPtr) {} \
313 static Name##Vtl sentinel_node; \
315 template <typename Key> \
316 Name##Vtl<Key> Name##Vtl<Key>::sentinel_node(sentinelCtor); \
317 template <typename Key> \
318 Name##Vtl<Key> * const Name##Vtl<Key>::NullPtr = \
319 &Name##Vtl<Key>::sentinel_node
324 template <
class Node>
330 template <
class Node>
340 template <
class Node>
346 template <
class Node>
356 template <
class Node>
358 typename Node::Key_Type &
KEY(
Node *p)
noexcept
363 template <
class Node>
365 const typename Node::Key_Type &
KEY(
const Node *p)
noexcept
370 template <
class Node>
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error()
Throws std::domain_error unconditionally.
Debug assertion and warning utilities.
Core definitions, constants, and utility macros for Aleph-w.
SentinelCtor
Tag type for sentinel node construction.
WeightedDigraph::Node Node
Node for binary search tree.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
#define DECLARE_BINNODE(Name, height, Control_Data)
Specify tree node for a binary tree.
Main namespace for Aleph-w library functions.
static void reset() noexcept
Empty_Node(SentinelCtor) noexcept
static Empty_Node & get_data()
static constexpr node_type *& left(node_type *p) noexcept
static const node_type * left(const node_type *p) noexcept
static constexpr node_type *& right(node_type *p) noexcept
static key_type & key(node_type *p) noexcept
static constexpr node_type * null() noexcept
static const key_type & key(const node_type *p) noexcept
typename Node::Key_Type key_type
static const node_type * right(const node_type *p) noexcept