38# include <gtest/gtest.h>
44using namespace testing;
49 return ((x != 0) && !(x & (x - 1))) != 0;
63 for (
size_t i = 0; i < 30; ++i)
135 const size_t n = m.capacity();
136 for (
size_t i = 0; i < n; ++i)
158 for (
size_t i = 0; i < m.size(); ++i, ++
k)
164 for (
size_t i = 0; i < m.size(); ++i)
168 for (
size_t i = 0; i < m.size(); ++i, ++
k)
176 const size_t dim = m.capacity();
184 for (
size_t i = 0; i < m.size(); ++i)
195 for (
size_t i = 0; i < m.size(); ++i, ++
k)
199 const size_t curr_cap = m.capacity();
200 const size_t avail = m.capacity() - m.
size();
220 const size_t cap1 = m.capacity();
224 for (
size_t i = 0; i < m.capacity(); ++i, ++
k)
233 for (
size_t i = 0; i < m.capacity(); ++i, ++
k)
240 for (
size_t i = 0; i < m.capacity(); ++i, ++
k)
249 for (
size_t i = m.size(); i < 2 *
cap1; ++i, ++
k)
257 for (
size_t i = 0; i < m.size(); ++i, ++
k)
267 const size_t cap = m.capacity();
272 m.reserve(2 * cap + 1);
282 for (
size_t i = 0; i < m.size(); ++i, ++
k)
292 for (
size_t i = 0; i < m.size(); ++i, ++
k)
299 auto ptr = m.get_ptr();
310 for (
size_t i = 0; i < m.size(); ++i, ++
k)
324 for (
size_t i = 0; i < m.size(); ++i, ++
k)
346 for (
size_t i = 0; i < m.size(); ++i, ++
k)
369 for (
size_t i = 0; i < 10; ++i)
373 for (
size_t k = 0;
k < 10; ++
k, ++
N)
381 for (
long i = 9; i >= 0; --i)
385 for (
auto it =
l.
get_it(); it.has_curr(); it.next(), ++n)
392 constexpr size_t num_items = 10;
395 for (
size_t i = 0; i < num_items; ++i)
399 for (
size_t k = 0;
k < num_items; ++
k, ++
N)
407 for (
size_t i = 0; i < num_items; ++i)
411 for (
size_t k = 0;
k < 10; ++
k, it.next(), --n)
420 for (
size_t i = 0; i < n; ++i)
426 size_t N = m.capacity();
427 for (
size_t i = 0; i < n; ++i)
430 if (m.size() ==
N / 4 - 1
and m.
size() > m.contract_threshold)
452 for (
size_t i = 0; i < 100; ++i)
455 for (
size_t i = 100; i > 0; --i)
521 for (
size_t i = 0; i < n; ++i)
T & get_curr() const
Get the current item with bounds checking.
void reset_last() noexcept
Reset the iterator to the last item.
void reset() noexcept
Reset the iterator to the first item.
void prev()
Move to the previous item with bounds checking.
void next()
Advance to the next item with bounds checking.
bool has_curr() const noexcept
Check if there is a current valid item.
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.
Simple, scalable and fast dynamic array.
bool traverse(Operation &operation)
Traverse all the elements from index 0 to n - 1 and execute operation on each on them.
size_t size() const noexcept
Return the number of elements.
T * get_ptr() const noexcept
Return the current base of array.
constexpr size_t capacity() const noexcept
The type of element of array.
bool is_empty() const noexcept
Return true is the array is empty.
T pop()
pop() the most recently pushed item
T & push(const T &item)
Push a copy of item at the beginning of sequence.
T remove_first()
Remove first item. Gap is closed.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_dim_function > > dim(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
Singly linked list implementations with head-tail access.
bool is_power_of_two(size_t x)
TEST_F(Default_MemArray, growing_in_2_powers)
Main namespace for Aleph-w library functions.
bool traverse(Node *root, Op op)
DynList< T > maps(const C &c, Op op)
Classic map operation.
Simple iterator on elements of array.
bool traverse(Operation &operation) noexcept(traverse_is_noexcept< Operation >())
Traverse the container via its iterator and performs a conditioned operation on each item.
Simple, scalable, contiguous dynamic array.