Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah_binnode_concepts_test.cc
Go to the documentation of this file.
1#include <gtest/gtest.h>
2
3#include <tpl_avl.H>
4#include <tpl_avlRk.H>
5#include <tpl_binNode.H>
6#include <tpl_binNodeUtils.H>
7#include <tpl_binNodeXt.H>
8#include <tpl_rand_tree.H>
9#include <tpl_rb_tree.H>
10#include <tpl_treap.H>
11#include <tpl_treapRk.H>
12
13// Positive/negative checks for BinNodeLike / RankedBinNodeLike (Phase 3 of
14// aleph-concepts-plan.md) and for the node utilities they now constrain.
15
16using namespace Aleph;
17
21// Utilities are also instantiated with const nodes, whose getL() returns by value.
22static_assert(BinNodeLike<const BinNode<int>>);
24
28
29// select() on a node without subtree sizes used to fail inside
30// tpl_binNodeXt.H ("no member named getCount"); now the call is not viable.
31template <class Node>
32concept can_select = requires(Node * r) { Aleph::select(r, size_t(0)); };
33template <class Node>
34concept can_compute_height = requires(Node * r) { computeHeightRec(r); };
35
38
40{
41 using Node = BinNodeXt<int>;
42 Node * root = Node::NullPtr;
43 for (int k : {5, 2, 8, 1, 9})
44 ASSERT_NE(insert_by_key_xt(root, new Node(k)), Node::NullPtr);
45
50}
51
52// Without a sentinel, nullptr is the empty tree and stays valid.
58
59#ifndef NDEBUG
60// With a sentinel (BinNodeXt), a nullptr root is a corrupted tree: debug
61// builds report it instead of dereferencing it.
63{
64 using Node = BinNodeXt<int>;
65 Node * root = nullptr;
66 EXPECT_DEATH((void) searchInBinTree(root, 1), "use Node::NullPtr");
67}
68#endif
WeightedDigraph::Node Node
@ KEY
Definition btreepic.C:169
Node for extended binary search tree.
Node for binary search tree.
#define TEST(name)
__gmp_expr< T, __gmp_binary_expr< __gmp_expr< T, U >, unsigned long int, __gmp_root_function > > root(const __gmp_expr< T, U > &expr, unsigned long int l)
Definition gmpfrxx.h:4071
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
Node * insert_by_key_xt(Node *&r, Node *p, Compare &cmp) noexcept
Insert a node in an extended binary search tree.
Node * select(Node *r, const size_t pos)
Iterative selection of a node according to inorder position.
void destroyRec(Node *&root) noexcept
Free recursively all the memory occupied by the tree root
Node * searchInBinTree(Node *root, const typename Node::key_type &key, const Compare &cmp=Compare()) noexcept
Search a key in a binary search tree.
size_t computeHeightRec(Node *root) noexcept
Compute recursively the height of root
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
and
Check uniqueness with explicit hash + equality functors.
static int * k
gsl_rng * r
AVL tree with rank (order statistics).
AVL tree implementation (height-balanced BST).
Utility functions for binary tree operations.
Extended binary node with subtree count.
Basic binary tree node definitions.
Randomized binary search tree.
Red-Black tree implementation (bottom-up balancing).
Treap with rank (order statistics).
Treap: randomized BST combining tree and heap properties.