19template <
typename T>
class BST;
20template <
typename T>
class AVLTree;
21template <
typename T>
class RBTree;
22template <
typename T>
class BinaryTree;
24template <
typename T>
class Node
36 std::int8_t m_height = 1;
66 static constexpr std::size_t CAPACITY = 4096;
67 alignas(
alignof(T) >
alignof(
void *) ?
alignof(T)
68 :
sizeof(
void *))
unsigned char data[CAPACITY *
sizeof(
Node<T>)];
72 std::vector<Block *> m_blocks;
73 std::vector<void *> m_free_list;
129 void dump_to_dot(
const std::string &filename)
const;
136 virtual int height()
const;
143 void insert_iterative(
Node<T> *node,
const T &val);
144 void remove_impl(
const T &val);
149 virtual void insert(
const T &val);
151 virtual void remove(
const T &val);
162 int get_height(
const Node<T> *node)
const;
163 int get_balance_factor(
const Node<T> *node)
const;
164 void update_height(
Node<T> *node);
171 void insert(
const T &val)
override;
172 void remove(
const T &val)
override;
173 int height()
const override;
179 void rotate_left(
Node<T> *node);
180 void rotate_right(
Node<T> *node);
181 void fix_insert_violation(
Node<T> *node);
185 int compute_black_height(
const Node<T> *node)
const;
186 bool validate_rb_helper(
const Node<T> *node)
const;
192 void insert(
const T &val)
override;
193 void remove(
const T &val)
override;
205#include "cppx/detail/avl.tpp"
206#include "cppx/detail/binary_tree.tpp"
207#include "cppx/detail/bst.tpp"
208#include "cppx/detail/node.tpp"
209#include "cppx/detail/node_pool.tpp"
210#include "cppx/detail/rbt.tpp"
int height() const override
void remove(const T &val) override
void insert(const T &val) override
T get_predecessor(const T &val) const
virtual void insert(const T &val)
T get_successor(const T &val) const
virtual void remove(const T &val)
bool contains(const T &val) const
int compute_size(const Node< T > *node) const
void print_levelorder() const
virtual int height() const
void destroy_subtree(Node< T > *node)
Node< T > * clone_subtree(const Node< T > *node)
void set_right(Node< T > *parent, Node< T > *right_child)
void postorder(const Node< T > *node) const
void set_left(Node< T > *parent, Node< T > *left_child)
void print_preorder() const
Node< T > * get_root() const
void dot_helper(const Node< T > *node, std::ostream &out, int &null_count) const
void inorder(const Node< T > *node) const
void print_tree_helper(const Node< T > *node, const std::string &prefix, bool is_left) const
void preorder(const Node< T > *node) const
void print_inorder() const
void levelorder(const Node< T > *node) const
BinaryTree & operator=(const BinaryTree &other)
void dump_to_dot(const std::string &filename) const
void print_postorder() const
void set_root(Node< T > *root)
Node< T > * make_node(const T &val)
NodePool(const NodePool &)=delete
void deallocate(Node< T > *node)
NodePool & operator=(const NodePool &)=delete
Node< T > * allocate(Args &&...args)
int get_height_val() const
const T & get_data() const
Node< T > * get_right() const
void set_right(Node< T > *node)
void set_left(Node< T > *node)
Node< T > * get_left() const
void set_parent(Node< T > *parent)
Node< T > * get_parent() const
void set_data(const T &val)
void set_height_val(int h)
static bool is_black(const Node< T > *node)
static bool is_red(const Node< T > *node)
bool validate_rb_properties() const
static Color get_color(const Node< T > *node)
std::vector< T > to_sorted_vector() const
void remove(const T &val) override
int get_black_height() const
void insert(const T &val) override