39# include <gtest/gtest.h>
44using namespace testing;
47constexpr size_t N = 17;
55 for (
size_t i = 0; i <
N; ++i, ++
n)
66 for (
size_t i = 0; i <
N; ++i, ++
n)
67 s.push({ int(i), 0, 1, 2, int(i) });
86 for (
size_t i = 0; i < m; ++i)
90 for (
size_t i = 0; i < m; ++i)
95 for (
size_t i = 0; i < m; ++i)
99 for (
size_t i = 0; i < m; ++i)
115 const size_t m = 100;
116 for (
size_t i = 0; i < m; ++i)
118 ASSERT_EQ(s.push({int(i), 0, 1, int(i)}).get_first(), i);
126 for (
size_t i = 0; i < m; ++i)
137 for (
size_t i = 0; i < m; ++i)
147 for (
size_t i = 0; i < m; ++i)
157 for (
size_t i = 0; i < n; ++i)
171 for (
size_t i = 0; i < m; ++i)
197 auto it = s.get_it();
198 for (
size_t i = 0; it.has_curr(); it.next(), ++i)
204 auto it = s.get_it();
205 for (
size_t i = 0; it.has_curr(); it.next(), ++i)
207 ASSERT_EQ(it.get_curr().get_first(), n - i -1);
208 ASSERT_EQ(it.get_curr().get_last(), n - i - 1);
312 bool ret = s.
traverse([&i,
N = n] (
int k) {
return (
k ==
N - i++ - 1); });
T & push(const T &data)
Push into stack a copy of data
Dynamic stack of elements of generic type T based on a singly linked list.
T & top()
Return a modifiable reference to the top item of the stack.
bool is_empty() const noexcept
Check if the stack is empty.
constexpr size_t size() const noexcept
Return the number of elements in the stack.
Dynamic singly linked list with functional programming support.
T & get_last() const
Return the last item of the list.
T & get_first() const
Return the first item of 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.
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(SimpleStack, push_pop)
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.
Fixture with a stack of complex objects (DynList<int>)
ArrayStack< DynList< int > > s
DynListStack< DynList< int > > s
bool traverse(Operation &operation) noexcept(traverse_is_noexcept< Operation >())
Traverse the container via its iterator and performs a conditioned operation on each item.
Fixture with a stack of integers.
Dynamic stack implementation based on linked lists.