38# include <gtest/gtest.h>
45using namespace testing;
48constexpr size_t N = 17;
56 for (
size_t i = 0; i <
N; ++i, ++
n)
71 for (
size_t i = 0; i <
N; ++i, ++
n)
72 q.put({ int(i), 1, 2, int(i) });
87 for (
int i = 0; i <
N; ++i)
96 for (
int i = 0; i <
N; ++i)
102 for (
int i = 0; i <
N; ++i)
118 for (
int i = q.size(); i < q.capacity(); ++i)
123 for (
size_t i = 0; i < q.size(); ++i)
129 const size_t nn = q.
size();
132 for (
size_t i = 0; i <
nn/2; ++i)
138 for (
size_t i = 0; i <
nn/2; ++i)
142 for (
size_t i = 0; i <
nn/2; ++i)
153 const size_t cap = q.capacity();
154 for (
size_t i = 0; i < cap; ++i)
157 for (
size_t i = 0; i < cap/4; ++i)
163 for (
size_t i = 0; i < cap/4; ++i)
166 for (
size_t i = 0; i < 3*cap/4; ++i)
170 for (
size_t i = 0; i < cap/4; ++i)
179 for (
int i = q.size(); i < q.capacity(); ++i)
190 for (
size_t i = 0; i < q.size(); ++i)
192 auto &
lf = q.front(i);
198 auto &
lr = q.rear(i);
205 const size_t nn = q.
size();
208 for (
size_t i = 0; i <
nn/2; ++i)
220 for (
size_t i = 0; i <
nn/2; ++i)
222 auto &
l = q.front(i);
230 for (
size_t i = 0; i <
nn/2; ++i)
247 const size_t cap = q.capacity();
248 for (
size_t i = 0; i < cap; ++i)
257 for (
size_t i = 0; i < cap/4; ++i)
269 for (
size_t i = 0; i < cap/4; ++i)
278 for (
size_t i = 0; i < 3*cap/4; ++i)
288 for (
size_t i = 0; i < cap/4; ++i)
308static size_t primes[] = {13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
309 61, 67, 71, 73, 79, 83, 89, 97, 197 };
317 for (
size_t i = 0; i <
N; ++i)
321 for (
auto it = q.
get_it(); it.has_curr(); it.next(), ++
k)
326 for (
size_t i = 0; i <
N/4; ++i)
333 for (
auto it = q.
get_it(); it.has_curr(); it.next(), ++
k)
338 for (
size_t i = 0; i <
N/4; ++i)
344 for (
auto it = q.
get_it(); it.has_curr(); it.next(), ++
k)
351 for (; it.has_curr(); it.prev(), --
k)
363 for (
size_t i = 0; i <
N; ++i)
372 for (
size_t i = 0; i <
N/4; ++i)
385 for (
size_t i = 0; i <
N/4; ++i)
408 for (
size_t i = 0; i <
N; ++i)
Functional programming utilities for Aleph-w containers.
T & put(const T &item)
Copy and put an item in the queue.
T & get_last() const
Return the last item of the list.
T & get_first() const
Return the first item of the list.
void empty() noexcept
empty the list
Very simple queue implemented with a contiguous array.
T & put(const T &item) noexcept
Put an item into the queue by copy.
bool traverse(Operation &operation)
Traverse all the elements from the youngest to the oldest and execute operation on each on them.
constexpr bool is_empty() const noexcept
Return true if the queue is empty.
T get() noexcept
Remove the oldest item of the queue.
void swap(FixedQueue &q) noexcept
constexpr size_t size() const noexcept
Return the number of items.
T & rear(const size_t i=0) const noexcept
Return the i-th youngest item.
constexpr size_t capacity() const noexcept
Return the queue capacity (maximum number of element to be stored)
T & front(const size_t i=0) const noexcept
Return the i-th oldest item.
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 for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
Type & nth(const size_t n)
Return the n-th item of container.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
TEST_F(SimpleQueue, put_and_get_stress)
Main namespace for Aleph-w library functions.
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
bool traverse(Node *root, Op op)
DynList< T > maps(const C &c, Op op)
Classic map operation.
FixedQueue< DynList< int > > q
ArrayQueue< DynList< int > > q
bool traverse(Operation &operation) noexcept(traverse_is_noexcept< Operation >())
Traverse the container via its iterator and performs a conditioned operation on each item.
Circular queue implementations backed by arrays.