21#define rbtnode RbtNode
Header file for the RBTree class and RbtNode class.
Definition redblack_tree.hpp:76
void fix_double_black(rbtnode *node)
Definition redblack_tree.cpp:289
rbtnode * BSTreplace(rbtnode *x)
Definition redblack_tree.cpp:272
RBTree()
Constructs a new RBTree object.
Definition redblack_tree.cpp:21
rbtnode * end()
Returns a pointer to the end of the red-black tree.
rbtnode * insert_node(rbtnode *root_node, rbtnode *node)
Definition redblack_tree.cpp:80
void add(book book_info)
Adds a new book to the red-black tree.
Definition redblack_tree.cpp:193
rbtnode * find(int key) const
Finds a book in the red-black tree based on the given key.
Definition redblack_tree.cpp:202
rbtnode * begin()
Returns a pointer to the first node in the red-black tree.
bool empty() const
Checks if the red-black tree is empty.
Definition redblack_tree.cpp:482
rbtnode * root
Definition redblack_tree.hpp:78
std::vector< int > findclosest(int targetId) const
Finds the closest book IDs to the given target ID in the red-black tree.
Definition redblack_tree.cpp:223
int color_flip_count
Definition redblack_tree.hpp:79
void rotate_right(rbtnode *&, rbtnode *&)
Definition redblack_tree.cpp:56
int ColorFlipCount()
Returns the number of color flips performed during tree operations.
Definition redblack_tree.cpp:27
rbtnode * successor(rbtnode *x)
Definition redblack_tree.cpp:262
rbtnode * operator[](int key) const
Overloads the subscript operator to find a book in the red-black tree based on the given key.
Definition redblack_tree.cpp:476
void remove(rbtnode *node)
Definition redblack_tree.cpp:388
void fix_colorviolation(rbtnode *&, rbtnode *&)
Definition redblack_tree.cpp:99
void rotate_left(rbtnode *&, rbtnode *&)
Definition redblack_tree.cpp:32
Represents a node in the red-black tree.
Definition redblack_tree.hpp:42
RbtNode * left
Definition redblack_tree.hpp:46
RbtNode(int k, const book &v)
Constructs a new RbtNode object.
Definition redblack_tree.hpp:58
RbtNode * right
Definition redblack_tree.hpp:47
RbtNode * sibling() const
Returns the sibling of the node.
Definition redblack_tree.cpp:5
int key
Definition redblack_tree.hpp:44
RbtNode * parent
Definition redblack_tree.hpp:48
Color color
Definition redblack_tree.hpp:49
book value
Definition redblack_tree.hpp:45
Represents a book in the library.
Definition book.hpp:24
Color
Represents the color of a node in the red-black tree.
Definition redblack_tree.hpp:32
@ BLACK
Definition redblack_tree.hpp:32
@ RED
Definition redblack_tree.hpp:32
#define rbtnode
Red-black tree node type.
Definition redblack_tree.hpp:21