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) });
97 for (
int i = 0; i <
N; ++i)
106 for (
int i = 0; i <
N; ++i)
112 for (
int i = 0; i <
N; ++i)
128 for (
int i = q.size(); i < q.capacity(); ++i)
133 for (
size_t i = 0; i < q.size(); ++i)
140 for (
size_t i = q.size(), n = 2*q.size(); i < n; ++i)
145 const size_t nn = q.
size();
148 for (
size_t i = 0; i <
nn/2; ++i)
154 for (
size_t i = 0; i <
nn/2; ++i)
158 for (
size_t i = 0; i <
nn/2; ++i)
169 const size_t cap = 16;
170 for (
size_t i = 0; i < cap; ++i)
173 for (
size_t i = 0; i < cap/4; ++i)
179 for (
size_t i = 0; i < cap/4; ++i)
182 for (
size_t i = 0; i < 3*cap/4; ++i)
186 for (
size_t i = 0; i < cap/4; ++i)
195 for (
int i = q.size(); i < q.capacity(); ++i)
206 for (
size_t i = 0; i < q.size(); ++i)
208 auto &
lf = q.front(i);
214 auto &
lr = q.rear(i);
222 for (
size_t i = q.size(), n = 2*q.size(); i < n; ++i)
233 const size_t nn = q.
size();
236 for (
size_t i = 0; i <
nn/2; ++i)
248 for (
size_t i = 0; i <
nn/2; ++i)
250 auto &
l = q.front(i);
258 for (
size_t i = 0; i <
nn/2; ++i)
275 const size_t cap = 16;
276 for (
size_t i = 0; i < cap; ++i)
285 for (
size_t i = 0; i < cap/4; ++i)
297 for (
size_t i = 0; i < cap/4; ++i)
306 for (
size_t i = 0; i < 3*cap/4; ++i)
316 for (
size_t i = 0; i < cap/4; ++i)
336static size_t primes[] = {13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
337 61, 67, 71, 73, 79, 83, 89, 97, 197 };
344 for (
size_t i = 0; i <
N; ++i)
348 for (
auto it = q.
get_it(); it.has_curr(); it.next(), ++
k)
353 for (
size_t i = 0; i <
N/4; ++i)
360 for (
auto it = q.
get_it(); it.has_curr(); it.next(), ++
k)
365 for (
size_t i = 0; i <
N/4; ++i)
371 for (
auto it = q.
get_it(); it.has_curr(); it.next(), ++
k)
378 for (; it.has_curr(); it.prev(), --
k)
390 for (
size_t i = 0; i <
N; ++i)
399 for (
size_t i = 0; i <
N/4; ++i)
411 for (
size_t i = 0; i <
N/4; ++i)
434 for (
size_t i = 0; i <
N; ++i)
Functional programming utilities for Aleph-w containers.
TEST_F(SimpleQueue, put_and_get_stress)
Queue implemented with a single dynamic array.
T & front(const size_t i=0) const
Return the i-th oldest item of the queue.
bool traverse(Operation &operation)
Traverse all the elements from the youngest to the oldest and execute operation on each on them.
T & getn(const size_t i)
Remove the i oldest items of the queue.
T & put(const T &item)
Copy and put an item in the queue.
T & rear(const size_t i=0) const
Return the i-th youngest item of the queue.
T get()
Remove the oldest item of the queue and return a copy.
void swap(ArrayQueue &q) noexcept
Swap this with q
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
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.
size_t size() const noexcept
Return the number of elements.
constexpr size_t capacity() const noexcept
The type of element of array.
bool is_empty() const noexcept
Return true is the array is empty.
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.
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.
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.