42#include <gtest/gtest.h>
47using namespace testing;
56 for (
size_t i = 0; i < arr.
size(); ++i)
57 out.push_back(arr[i]);
62 std::vector<typename Tree::key_type>
to_vector(
const Tree & tree)
98 std::vector<int>
ref_range(
const std::set<int> &
ref,
int first,
int last)
100 std::vector<int>
out;
104 for (
auto it =
ref.lower_bound(first);
105 it !=
ref.end()
and *it <= last;
137 Tree tree = {40, 10, 90, 10, 20, 70, 40, 60, 30, 50};
148 for (
int i = 1; i <= 40; ++i)
166 for (
int value : {105, 110, 115, 120, 125, 130, 135, 140, 145, 150})
170 for (
auto it = tree.get_it(); it.has_curr(); it.next_ne())
173 (std::vector<int>{105, 110, 115, 120, 125, 130, 135, 140, 145, 150}));
175 std::vector<int>
band;
176 auto band_it = tree.get_range_it(118, 141);
184 EXPECT_EQ(
band, (std::vector<int>{120, 125, 130, 135, 140}));
192 for (
int i = 1; i <= 60; ++i)
198 for (
int value : {1, 2, 3, 6, 7, 8, 17, 18, 19, 28, 29, 30, 42, 43, 44, 60, 59})
212 Tree tree = {50, 20, 70, 10, 30, 60, 80, 25, 27};
235 Tree tree = {1, 2, 3};
236 EXPECT_THROW((
void) tree.range(10, 5), std::invalid_argument);
243 std::mt19937
rng(0xBEEFBEEF);
244 std::uniform_int_distribution<int>
op_dist(0, 6);
245 std::uniform_int_distribution<int>
value_dist(-80, 180);
268 const auto it =
ref.lower_bound(value);
270 it ==
ref.end() ? std::nullopt : std::optional<int>(*it);
277 const auto it =
ref.upper_bound(value);
279 it ==
ref.end() ? std::nullopt : std::optional<int>(*it);
TEST_F(BPlusTreeTest, EmptyTreeReportsNoKeys)
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.
QuadTree - Hierarchical spatial index for 2D points.
void empty(Node *&r) noexcept
Recursively delete all nodes.
void remove(const Point &p)
Remove a point from the tree.
bool contains(const Point &p) const noexcept
Check if a point is within the tree's region.
Point * insert(Node *&r, const Point &p)
Recursive insert helper.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
std::vector< typename C::Item_Type > to_vector(const C &c)
Convert a container to a std::vector.
B+ Tree implementation with linked leaves and configurable degree.