38# include <gtest/gtest.h>
43using namespace testing;
46# define Declare_list_n_items(num) \
47 struct List_of_##num##_items : public Test \
50 DynDlist<int> list##num; \
51 DynDlist<int> rlist##num; \
52 List_of_##num##_items() \
54 for (size_t i = 0; i < num; ++i, ++n) \
55 list##num.append(i + 1); \
57 const DynDlist<int> l = list##num; \
58 rlist##num = l.rev(); \
166 auto it1 = list10.get_it();
168 for (; it1.has_curr()
and it2.has_curr(); it1.next(), it2.next())
169 ASSERT_EQ(it1.get_curr(), it2.get_curr());
184 for (
auto it =
tmp.
get_it(); it.has_curr(); it.next(), ++i)
195 for (
auto it = aux.
get_it(); it.has_curr(); it.next(), ++i)
207 for (
auto it = aux.
get_it(); it.has_curr(); it.next(), ++i)
216 for (
auto it = list10.get_it(); it.has_curr(); it.next(), ++i)
233 list25.for_each([] (
auto i) {
cout << i <<
" "; });
cout <<
endl;
235 auto it = list25.
get_it();
236 for (; it.has_curr(); it.next(), ++i)
245 for (; it.has_curr(); it.prev(), --i)
267 for (
auto it =
l.
get_it(); it.has_curr(); it.next(), ++i)
270 for (
auto it = r.
get_it(); it.has_curr(); it.next(), ++i)
276 for (
auto it =
l.
get_it(); it.has_curr(); it.next(), ++i)
290 for (
auto it =
laux.
get_it(); it.has_curr(); it.next(), ++i)
298 for (
auto it = list25.get_it(); it.has_curr(); it.next(), --i)
304 for (
auto it = list25.get_it(); it.has_curr(); it.next(), ++i)
319 for (
auto it = list25.get_it(); it.has_curr(); it.next(), ++i)
328 auto it = list25.get_it();
329 for (
int i = 0, n = 4; i < 3; ++i, ++n, it.next())
333 list25.rotate_left(22);
335 for (
auto it = list25.get_it(); it.has_curr(); it.next(), ++i)
341 list25.rotate_right(3);
344 auto it = list25.
get_it();
345 for (
int i = 0, n = 23; i < 3; ++i, ++n, it.next())
349 list25.rotate_right(22);
351 for (
auto it = list25.get_it(); it.has_curr(); it.next(), ++i)
363 list25.append(std::move(
lg));
369 for (
auto it = list25.get_it(); it.has_curr(); it.next(), ++i)
377 auto ret = m.
traverse([&n] (
int) { ++n;
return true; });
387 auto ret = list25.
traverse([&
N,
this] (
int i) { ++
N;
return i < n/2; });
395 for (
int i = 1; i <= 4; ++i)
403 for (
auto it = list.
get_it(); it.has_curr(); it.next(), ++idx)
416 for (
int i = 0; i < 5; ++i)
496 it.append_list(head);
constexpr bool is_unitarian_or_empty() const noexcept
Return true if this (as header node) has zero or one element.
constexpr bool is_empty() const noexcept
Return true if this (as header node) is empty.
constexpr bool is_unitarian() const noexcept
Return true if this (as header node) has exactly one element.
void rotate_left(size_t n)
Rotate to left the list n positions.
Dynamic doubly linked list with O(1) size and bidirectional access.
T & get_last() const
Return a modifiable reference to last item in the list.
const size_t & size() const noexcept
Return the number of elements (constant time)
DynDlist & reverse() noexcept
T & front()
If this was treated as a queue, the it returns the most oldlest inserted item.
void remove(T &data) noexcept
Assuming that data is a reference to the item in the list, it removes the item.
void empty() noexcept
Empty the list.
T & append(const T &item)
Append a copied item at the end of the list.
T & rear()
If this was treated as a queue, the it returns the most recently inserted item.
void split(DynDlist &l, DynDlist &r)
This is an overloaded member function, provided for convenience. It differs from the above function o...
T & get_first() const
Return a modifiable reference to first item in the list.
void erase(T &data) noexcept
T & insert(const T &item)
Insert a copy of item at the beginning of the list.
T remove_first()
Remove the first item of the list; return a copy of removed item.
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.
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.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
iterator end() noexcept
Return an STL-compatible end iterator.
TEST_F(List_of_10_items, copy_and_assignment)
#define Declare_list_n_items(num)
Main namespace for Aleph-w library functions.
void reverse(Itor beg, Itor end)
Reverse elements in a range.
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.
void rotate_right(T *ptr, const size_t n, size_t m) noexcept
Rotate array elements right 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.
Dynamic doubly linked list implementation.