41#include <gtest/gtest.h>
50 size_t count_nodes(
Node *
root)
noexcept
52 if (
root == Node::NullPtr)
60 std::vector<typename Node::key_type> keys;
61 if (
root == Node::NullPtr)
65 keys.insert(keys.end(), left.begin(), left.end());
68 keys.insert(keys.end(), right.begin(), right.end());
82 std::vector<Node *> allocated;
86 auto * p =
new Node(
k);
87 allocated.push_back(p);
93 for (
auto & q : allocated)
103 for (
auto * p : allocated)
110 bool use_abs =
false;
112 StatefulLess() =
default;
113 explicit StatefulLess(
bool b) : use_abs(b) {}
115 bool operator()(
int a,
int b)
const
145 auto * p = pool.make(7);
160 auto * p1 = pool.make(10);
163 auto * p2 = pool.make(10);
178 for (
int i = 0; i < 5; ++i)
185 EXPECT_EQ(keys, (std::vector<int>{42, 42, 42, 42, 42}));
195 for (
int k : {5, 3, 7, 1, 4, 6, 8})
213 for (
int k : {1, 3, 5})
235 auto * p1 = pool.make(10);
238 auto * p2 = pool.make(10);
254 for (
int k : {1, 2, 3, 4, 5})
270 EXPECT_EQ(keys, (std::vector<int>{1, 2, 4, 5}));
281 for (
int k : {1, 2, 3, 4, 5})
299 Tree tree(StatefulLess(
true));
302 auto * p = pool.make(1);
WeightedDigraph::Node Node
bool verify() const
Return true if this is a consistent randomized tree.
Node * remove(const Key &key) noexcept
Remove a key from the tree.
Node * search_or_insert(Node *p) noexcept
Search or insert a key.
Node * insert_dup(Node *p) noexcept
Insert a node in the tree.
Node * insert(Node *p) noexcept
Insert a node in the tree.
Node *& getRoot() noexcept
Return the tree's root.
Node * search(const Key &key) const noexcept
Search a key.
Node *& getRoot() noexcept
Get the top-down splay tree's root.
Node * remove(const Key &key) noexcept
Remove a key from a top down splay tree.
Node * search(const Key &key) noexcept
Searches a key in a top-down splay tree.
__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)
constexpr Node *& RLINK(Node *p) noexcept
Return the right tree of p.
constexpr Node *& LLINK(Node *p) noexcept
Return a pointer to left subtree.
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
std::vector< int > inorder_keys(NodeT *root)
Top-down splay tree implementation (without rank support).