46# ifndef TPL_SPLAY_TREE_H
47# define TPL_SPLAY_TREE_H
134template <
template <
class>
class NodeType,
typename Key,
class Compare>
176 else if (
cmp(
tk, key))
203 LLINK(t) = headNode.getR();
204 RLINK(t) = headNode.getL();
223 void splay(
const Key & key)
noexcept
237 std::swap(
root, tree.root);
238 std::swap(
cmp, tree.cmp);
247 const Key &
pk =
KEY(p);
273 assert(p != Node::NullPtr);
277 if (
root == Node::NullPtr)
280 const Key & key =
KEY(p);
292 assert(p != Node::NullPtr);
296 if (
root == Node::NullPtr)
313 if (
root == Node::NullPtr)
323 if (
root == Node::NullPtr)
326 const Key & key =
KEY(p);
345 if (
root == Node::NullPtr)
393template <
typename Key,
class Compare = Aleph::less<Key>>
402template <
typename Key,
class Compare = Aleph::less<Key>>
C++20 concepts for constraining comparison functors.
Inorder iterator on the nodes of a binary tree.
Top-down splay tree - Self-adjusting BST with amortized O(log n) operations.
static constexpr signed char CmpEqual
Key key_type
The key type stored in the node.
Compare & get_compare() noexcept
static constexpr signed char CmpLess
Node *& getRoot() noexcept
Get the top-down splay tree's root.
Compare & key_comp() noexcept
Returns a reference to the comparison criteria.
virtual ~GenTdSplayTree()=default
Destructor.
Node * insert_dup(Node *p) noexcept
GenTdSplayTree(Compare __cmp=Compare()) noexcept
Constructor.
static constexpr signed char CmpGreater
Node * remove(const Key &key) noexcept
Remove a key from a top down splay tree.
Node * insert(Node *p) noexcept
Inserts a node in a top-down splay tree.
Node * search(const Key &key) noexcept
Searches a key in a top-down splay tree.
Node * search_or_insert(Node *p) noexcept
signed char splay_impl(const Key &key) noexcept
void swap(GenTdSplayTree &tree) noexcept
Node * __insert(Node *p) noexcept
void splay(const Key &key) noexcept
search key within tree and splay that node, if not found it return Node::NullPtr
Node * rotate_to_left(Node *p) noexcept
Rotate to the left the tree with root p
Node * rotate_to_right(Node *p) noexcept
Rotate to the right the tree with root p
bool check_bst(Node *p, const Compare &cmp=Compare())
Return true if p is a binary search tree.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Iterator() noexcept=default
Default constructor creates an "end" iterator.
Utility functions for binary tree operations.
Basic binary tree node definitions.