48 static ofstream
output(
"bin-tree-aux.Tree", ios::out);
51 output << p->get_key() <<
" ";
57 static ofstream example(
"example-34-ar-aux.Tree", ios::out);
58 if (not example.is_open())
60 example << p->get_key() <<
" ";
65 static ofstream tex(
"example-34-aux.tex", ios::out);
66 if (not tex.is_open())
68 tex <<
" $" << p->get_key() <<
"\\ $";
72int main(
int argc,
char *argv[])
77 try { n = stoi(argv[1]); }
78 catch (...) { n = 1000; }
81 unsigned int t = std::time(0);
84 try { t =
static_cast<unsigned int>(stoul(argv[2])); }
85 catch (...) { t = std::time(0); }
90 cout <<
"writeBinTree " << n <<
" " << t << endl;
95 for (
int i = 0; i < 30; i++)
100 value = std::uniform_int_distribution<int>(0, 499)(
rng);
102 }
while (node not_eq NULL);
112 for (
int i = 0; i < n; i++)
117 value = std::uniform_int_distribution<int>(0, n * 10 - 1)(
rng);
119 }
while (node not_eq NULL);
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error()
Throws std::runtime_error unconditionally.
Core header for the Aleph-w library.
size_t size_t int32_t value
Node * insert(Node *p) noexcept(nothrow_compare_copy_v< Compare, Key >)
Insert a node in the tree.
Node *& getRoot() noexcept
Return the root of tree.
Node * search(const Key &key) const noexcept(nothrow_compare_copy_v< Compare, Key >)
Search a key.
int preOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively in preorder a binary tree.
int inOrderRec(Node *root, void(*visitFct)(Node *, int, int))
Traverse recursively inorder a binary tree.
void destroyRec(Node *&root) noexcept
Free all the memory occupied by the tree root
Main namespace for Aleph-w library functions.
Binary search tree with nodes without virtual destructors,.
Utility functions for binary tree operations.
Generic unbalanced binary search tree.
static void print_key(BinTree< int >::Node *p, int, int)
static void print_tex(BinTree< int >::Node *p, int, int)
static void print_ex(BinTree< int >::Node *p, int, int)