55 file << p->get_key() <<
" ";
68 output << p->get_key() <<
" ";
79int main(
int argc,
char *argv[])
82 unsigned int t = std::time(0);
87 try { n = std::stoi(argv[1]); }
88 catch (
const std::exception & e)
90 cerr <<
"Warning: could not parse n from '" << argv[1]
91 <<
"': " << e.what() <<
". Using default n=1000" << endl;
97 try { t = std::stoi(argv[2]); }
98 catch (
const std::exception & e)
100 cerr <<
"Warning: could not parse t from '" << argv[2]
101 <<
"': " << e.what() <<
". Using default t=" << t << endl;
107 cout <<
"n must be positive" << endl;
113 output.open(
"rb-example-aux.Tree", ios::out);
116 cerr <<
"Error: could not open rb-example-aux.Tree for writing" << endl;
120 file.open(
"rb-tree-aux.Tree", ios::out);
121 if (not
file.is_open())
123 cerr <<
"Error: could not open rb-tree-aux.Tree for writing" << endl;
127 cout <<
"writeRb " << n <<
" " << t << endl;
134 for (i = 0; i < 30; i++)
138 value = (int) (100.0*std::rand()/(RAND_MAX+1.0));
140 }
while (node not_eq NULL);
148 output << endl <<
"START-SHADOW ";
159 for (i = 0; i < n; i++)
163 value = (int) (n*10.0*std::rand()/(RAND_MAX+1.0));
165 }
while (node not_eq NULL);
173 file <<
"START-SHADOW ";
Core header for the Aleph-w library.
size_t size_t int32_t value
Node * search(const Key &key) const noexcept(nothrow_compare_v< Compare, Key >)
Search for a key in the tree.
Node * insert(Node *p) noexcept(nothrow_compare_v< Compare, Key >)
Insert a node into the tree.
Node *& getRoot() noexcept
Get reference to root pointer.
void destroyRec(Node *&root) noexcept
Free all the memory occupied by the tree root
Main namespace for Aleph-w library functions.
#define RED
Red color constant (newly inserted nodes are red)
bool is_red_black(Node *node)
Test all Red-Black tree properties for a node.
Red-black tree with nodes without virtual destructor.
Utility functions for binary tree operations.
Red-Black tree implementation (bottom-up balancing).
static void print_color_ex(const Rb_Tree< int >::Node *p, int, int pos)
static void print_color(const Rb_Tree< int >::Node *p, int, int pos)
static void print_key(const Rb_Tree< int >::Node *p, int, int)
static void print_key_ex(const Rb_Tree< int >::Node *p, int, int)