38# include <gtest/gtest.h>
42using namespace testing;
52 for (
size_t i = 0; i < 25; ++i, ++
n)
139 for (
auto it = list.get_it(); it.has_curr(); it.next(), ++i)
160 for (
auto it =
l.
get_it(); it.has_curr(); it.next(), ++i)
163 for (
auto it = r.
get_it(); it.has_curr(); it.next(), ++i)
169 for (
auto it =
l.
get_it(); it.has_curr(); it.next(), ++i)
183 for (
auto it =
laux.
get_it(); it.has_curr(); it.next(), ++i)
191 for (
auto it = list.get_it(); it.has_curr(); it.next(), --i)
197 for (
auto it = list.get_it(); it.has_curr(); it.next(), ++i)
219 EXPECT_EQ(it.get_curr()->to_data<
int>(), i);
228 auto it = list.get_it();
229 for (
int i = 0, n = 4; i < 3; ++i, ++n, it.next())
233 list.rotate_left(22);
235 for (
auto it = list.get_it(); it.has_curr(); it.next(), ++i)
247 list.append(std::move(
lg));
253 for (
auto it = list.get_it(); it.has_curr(); it.next(), ++i)
261 auto ret = m.
traverse([&n] (
int) { ++n;
return true; });
271 auto ret = list.
traverse([&
N,
this] (
int i) { ++
N;
return i < n/2; });
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.
T & get_last() const
Return the last item of the list.
T & get_first() const
Return the first item of the list.
DynList & reverse() noexcept
DynList & swap(DynList &l) noexcept
Swap this with l.
bool has_curr() const noexcept
Return true if iterator has current item.
constexpr bool is_empty() const noexcept
Return true if list is empty.
void rotate_left(size_t n)
Rotate to left the list n positions.
size_t split(HTList &l, HTList &r) noexcept
size_t size() const noexcept
Count the number of elements of the list.
bool is_unitarian() const noexcept
Return true if the list contains exactly just one element.
bool is_unitarian_or_empty() const noexcept
Return true if list contains one element or is empty.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
TEST_F(List_of_25_items, Basic_operations)
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
void reverse(Itor beg, Itor end)
Reverse elements in a range.
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
T & swap(T &t1, T &t2)
Generic swap using object's swap method.
bool traverse(Node *root, Op op)
void rotate_left(T *ptr, const size_t n, size_t m) noexcept
Rotate array elements left by m positions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
bool traverse(Operation &operation) noexcept(traverse_is_noexcept< Operation >())
Traverse the container via its iterator and performs a conditioned operation on each item.