38#include <gtest/gtest.h>
43using namespace testing;
57TEST(RandomSet, AppendReturnsReference)
65 q.
traverse([&found] (
const int v) { found |= (v == 13);
return true; });
69TEST(RandomSet, AppendPreservesUniformityBySwapping)
72 for (
int i = 0; i < 10; ++i)
76 auto &first = q.
append(100);
90TEST(RandomSet, GetRemovesUniformly)
104TEST(RandomSet, AppendMoveAcceptsComplexTypes)
110 explicit Payload(std::string d) : data(std::move(d)) {}
114 const auto &stored = q.
append(Payload(
"beta"));
115 EXPECT_EQ(
"beta", stored.data);
117 auto &stored2 = q.
append(Payload(
"gamma"));
118 stored2.data =
"delta";
121 q.
traverse([&hits] (
const Payload &p)
123 if (p.data ==
"delta" || p.data ==
"beta")
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.
bool traverse(Operation &operation) noexcept(noexcept(array.traverse(operation)))
Conditional traversing of the random queue.
Main namespace for Aleph-w library functions.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Random access queue (bag) with O(1) random pop.