49 std::cout << label <<
" [";
50 for (
size_t i = 0; i < values.
size(); ++i)
54 std::cout << values[i];
66 Catalog catalog = {40, 10, 90, 20, 70, 60, 30, 50, 80};
68 std::cout <<
"B-Tree example\n";
69 std::cout <<
"==============\n";
71 std::cout <<
"height : " << catalog.height() <<
'\n';
73 if (
const auto lb = catalog.lower_bound(55); lb.has_value())
74 std::cout <<
"lower_bound(55) -> " << *lb <<
'\n';
76 if (
const auto ub = catalog.upper_bound(60); ub.has_value())
77 std::cout <<
"upper_bound(60) -> " << *ub <<
'\n';
86 <<
"B_Tree example produced an invalid tree";
88 std::cout <<
"\nafter updates\n";
89 std::cout <<
"-------------\n";
91 std::cout <<
"size : " << catalog.size() <<
'\n';
92 std::cout <<
"height : " << catalog.height() <<
'\n';
94 if (
const auto mn = catalog.min_key(); mn.has_value())
95 std::cout <<
"min : " << *mn <<
'\n';
97 if (
const auto mx = catalog.max_key(); mx.has_value())
98 std::cout <<
"max : " << *mx <<
'\n';
100 std::cout <<
"\nB-Tree keeps data sorted while internal nodes also hold keys.\n";
102 catch (
const std::exception & ex)
104 std::cerr <<
"b_tree_example failed: " << ex.what() <<
'\n';
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_unless(C)
Throws std::runtime_error if condition does NOT hold.
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
Generic B-Tree with configurable minimum degree.
Main namespace for Aleph-w library functions.
void print_array(const char *label, const Container &a)
B-Tree implementation with configurable minimum degree.