38#include <gtest/gtest.h>
93 std::set<int> inserted = {1, 2, 3, 4, 5};
94 for (
int x : inserted)
98 while (!rset.is_empty())
143 int&
ref = rset.append(42);
164 while (!rset.is_empty())
166 while (!
copy.is_empty())
202 other = std::move(rset);
221 std::set<int>
expected = {1, 2, 3, 4, 5};
239 std::vector<int>
vec = {1, 2, 3, 4, 5};
257 for (
int i = 0; i <
N; ++i)
259 rset1.set_seed(12345);
260 std::vector<int>
seq1;
261 while (!
rset1.is_empty())
266 for (
int i = 0; i <
N; ++i)
268 rset2.set_seed(67890);
269 std::vector<int>
seq2;
270 while (!
rset2.is_empty())
274 EXPECT_NE(
seq1,
seq2) <<
"Different seeds should produce different extraction orders";
281 for (
int i = 0; i < 10; ++i)
287 rset1.set_seed(12345);
288 rset2.set_seed(12345);
291 while (!
rset1.is_empty())
293 while (!
rset2.is_empty())
309 std::set<int> visited;
310 rset.traverse([&visited](
int x) {
321 for (
int i = 1; i <= 10; ++i)
325 rset.traverse([&
count](
int) {
340 for (
int i = 0; i < 10; ++i)
359 for (
int i = 0; i < 100; ++i)
381 std::string s =
"hello";
382 rset.
put(std::move(s));
392 std::string s =
"world";
393 rset.
append(std::move(s));
407 for (
int i = 0; i <
N; ++i)
417 for (
int i = 0; i <
N; ++i)
428 for (
int i = 0; i < 100; ++i)
432 for (
int i = 0; i < 50; ++i)
461 while (!rset.is_empty())
473 ::testing::InitGoogleTest(&
argc,
argv);
Dynamic singly linked list with functional programming support.
T & append(const T &item)
size_t size() const noexcept
Count the number of elements of the list.
void put(const T &item)
Insert an item by copy.
bool is_empty() const
Return true if the queue is empty.
T get()
Extract randomly an item.
T & append(const T &item)
Insert randomly an item by copy.
size_t size() const
Return the number of items in the queue.
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
Main namespace for Aleph-w library functions.
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.
auto shuffle(const C< T > &c)
Randomly shuffle a sequence.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
Dynamic doubly linked list implementation.
Random access queue (bag) with O(1) random pop.
TEST_F(RandomSetTest, InitiallyEmpty)