Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
search_trees_test_common.H
Go to the documentation of this file.
1/*
2 Aleph_w
3
4 / \ | | ___ _ __ | |__ __ __
5 / _ \ | |/ _ \ '_ \| '_ \ ____\ \ /\ / /
6 / ___ \| | __/ |_) | | | |_____\ V V /
7 /_/ \_\_|\___| .__/|_| |_| \_/\_/
8 |_|
9
10 This file is part of Aleph-w library
11
12 Copyright (c) 2002-2026 Leandro Rabindranath Leon
13
14 Permission is hereby granted, free of charge, to any person obtaining a copy
15 of this software and associated documentation files (the "Software"), to deal
16 in the Software without restriction, including without limitation the rights
17 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 copies of the Software, and to permit persons to whom the Software is
19 furnished to do so, subject to the following conditions:
20
21 The above copyright notice and this permission notice shall be included in all
22 copies or substantial portions of the Software.
23
24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 SOFTWARE.
31*/
32
39# ifndef SEARCH_TREES_TEST_COMMON_H
40# define SEARCH_TREES_TEST_COMMON_H
41
42# include <gtest/gtest.h>
43
44# include <cstddef>
45# include <memory>
46# include <string>
47# include <vector>
48
49# include <tpl_avl.H>
50# include <tpl_avlRk.H>
51# include <tpl_binNodeUtils.H>
52# include <tpl_binTree.H>
53# include <tpl_hRbTree.H>
54# include <tpl_hRbTreeRk.H>
55# include <tpl_rand_tree.H>
56# include <tpl_rbRk.H>
57# include <tpl_rb_tree.H>
58# include <tpl_splay_tree.H>
59# include <tpl_splay_treeRk.H>
60# include <tpl_tdRbTree.H>
61# include <tpl_tdRbTreeRk.H>
62# include <tpl_treap.H>
63# include <tpl_treapRk.H>
64
66{
67 // Most of the trees are in Aleph; the splay trees are in the global
68 // namespace.
69 using namespace Aleph;
70
72 template <class Node>
73 concept Colored_Node = requires(Node * p) { p->getColor(); };
74
76 template <class Node>
77 concept Avl_Balanced_Node = requires(Node * p) { p->getDiff(); };
78
80 template <class Node>
81 concept Counted_Node = requires(Node * p) { p->getCount(); };
82
84 template <class Node>
85 concept Prioritized_Node = requires(Node * p) { p->getPriority(); };
86
88 template <class Tree>
89 concept Seeded_Tree = requires(Tree & tree) { tree.set_seed(1UL); };
90
92 template <class Node>
94 {
95 std::vector<std::unique_ptr<Node>> nodes;
96
97 public:
98 Node * make(const int key)
99 {
100 nodes.push_back(std::make_unique<Node>(key));
101 return nodes.back().get();
102 }
103
104 [[nodiscard]] size_t size() const noexcept { return nodes.size(); }
105 };
106
108 template <class Tree>
109 struct Tree_Name;
110
111# define SEARCH_TREES_TEST_NAME(Tree) \
112 template <> \
113 struct Tree_Name<Tree<int>> \
114 { \
115 static constexpr const char * value = #Tree; \
116 }
117
132
133# undef SEARCH_TREES_TEST_NAME
134
137 {
138 template <class Tree>
139 static std::string GetName(int)
140 {
142 }
143 };
144
146 using All_Trees = ::testing::Types<
152
154 using Ranked_Trees = ::testing::Types<
158
160 using Red_Black_Trees = ::testing::Types<
163
165 using Avl_Trees = ::testing::Types<Avl_Tree<int>, Avl_Tree_Rk<int>>;
166
168 using Treaps = ::testing::Types<Treap<int>, Treap_Rk<int>>;
169}
170
171# endif // SEARCH_TREES_TEST_COMMON_H
WeightedDigraph::Node Node
Hybrid top-down/bottom-up red-black tree with rank support.
Hybrid top-down/bottom-up red-black tree.
Definition tpl_hRbTree.H:86
Top-down red-black tree with rank (no virtual destructor).
Top-down red-black tree without virtual destructor.
QuadTree - Hierarchical spatial index for 2D points.
Definition quadtree.H:126
Owns the nodes of a tree, which does not free them.
std::vector< std::unique_ptr< Node > > nodes
The node stores the AVL balance factor.
The node has a red or black color.
The node stores the size of its subtree.
The node stores a heap priority.
The tree draws random numbers, from a seed that can be set.
Main namespace for Aleph-w library functions.
::testing::Types< Avl_Tree_Rk< int >, Rb_Tree_Rk< int >, TdRbTreeRk< int >, HtdRbTreeRk< int >, Treap_Rk< int >, Rand_Tree< int >, Splay_Tree_Rk< int > > Ranked_Trees
The trees whose nodes count the nodes of their subtree.
::testing::Types< BinTree< int >, Avl_Tree< int >, Avl_Tree_Rk< int >, Rb_Tree< int >, Rb_Tree_Rk< int >, TdRbTree< int >, TdRbTreeRk< int >, HtdRbTree< int >, HtdRbTreeRk< int >, Treap< int >, Treap_Rk< int >, Rand_Tree< int >, Splay_Tree< int >, Splay_Tree_Rk< int > > All_Trees
Every binary search tree of the library.
::testing::Types< Rb_Tree< int >, Rb_Tree_Rk< int >, TdRbTree< int >, TdRbTreeRk< int >, HtdRbTree< int >, HtdRbTreeRk< int > > Red_Black_Trees
The red-black trees.
::testing::Types< Treap< int >, Treap_Rk< int > > Treaps
The treaps.
::testing::Types< Avl_Tree< int >, Avl_Tree_Rk< int > > Avl_Trees
The AVL trees.
#define SEARCH_TREES_TEST_NAME(Tree)
Ranked AVL tree with nodes without a virtual destructor.
Definition tpl_avlRk.H:1592
AVL binary search tree with nodes without a virtual destructor.
Definition tpl_avl.H:831
Binary search tree with nodes without virtual destructors,.
Randomized binary search tree.
Red-Black binary search tree with nodes without virtual destructor and with subtree counters for sele...
Definition tpl_rbRk.H:1653
Red-black tree with nodes without virtual destructor.
Extended treap (a special type of randomized binary search tree) which manages selection and splittin...
Treap (a special type of randomized binary search tree) using nodes without virtual destructor.
Definition tpl_treap.H:797
The name a tree type shows in the name of its tests.
Names the instances of a typed test suite after their tree.
AVL tree with rank (order statistics).
AVL tree implementation (height-balanced BST).
Utility functions for binary tree operations.
Generic unbalanced binary search tree.
Hybrid top-down/bottom-up red-black tree with rank support.
Hybrid top-down/bottom-up red-black tree implementation.
Randomized binary search tree.
Red-Black tree with rank (order statistics).
Red-Black tree implementation (bottom-up balancing).
Top-down splay tree with rank support.
Top-down splay tree implementation (without rank support).
Top-down Red-Black tree with rank support.
Top-down Red-Black tree implementation.
Treap with rank (order statistics).
Treap: randomized BST combining tree and heap properties.