38#include <gtest/gtest.h>
93 std::set<int>
inserted = {1, 2, 3, 4, 5};
98 while (!rset.is_empty())
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;
266 for (
int i = 0; i <
N; ++i)
268 rset2.set_seed(67890);
269 std::vector<int>
seq2;
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);
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 & insert(const T &item)
Insert a new item by copy.
T & append(const T &item)
Append a new item by copy.
constexpr bool is_empty() const noexcept
Return true if list is empty.
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.
iterator end() noexcept
Return an STL-compatible end iterator.
iterator begin() noexcept
Return an STL-compatible iterator to the first element.
Main namespace for Aleph-w library functions.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
auto shuffle(const C< T > &c)
Randomly shuffle a sequence.
DynList< T > maps(const C &c, Op op)
Classic map operation.
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.
bool traverse(Operation &operation) noexcept(traverse_is_noexcept< Operation >())
Traverse the container via its iterator and performs a conditioned operation on each item.
Dynamic doubly linked list implementation.
Random access queue (bag) with O(1) random pop.
TEST_F(RandomSetTest, InitiallyEmpty)