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.
Type & nth(const size_t n)
Return the n-th item of the 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.
and
Check uniqueness with explicit hash + equality functors.
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)
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Fixture with a stack of complex objects (DynList<int>)
ArrayStack< DynList< int > > s
DynListStack< DynList< int > > s
Fixture with a stack of integers.
FooMap m(5, fst_unit_pair_hash, snd_unit_pair_hash)
Dynamic stack implementation based on linked lists.