38# include <gtest/gtest.h>
43using namespace testing;
51 for (
size_t i = 0; i < 25; ++i)
157 EXPECT_EQ(list.get_first(), list.get_head());
158 EXPECT_EQ(list.get_last(), list.get_tail());
186 EXPECT_EQ(it.get_curr()->to_snodenc<
int>()->get_data(), i);
206 EXPECT_EQ(it.get_curr()->to_data<
int>(), i);
209 EXPECT_EQ(it.get_curr()->to_data<
int>(), i);
215 EXPECT_EQ(it.get_curr()->to_data<
int>(), i);
229 EXPECT_EQ(it.get_curr()->to_data<
int>(), i);
237 for (
size_t i = 1; i < 13; ++i, it.
next())
263 EXPECT_EQ(it.get_curr()->to_data<
int>(), i);
269 EXPECT_EQ(it.get_curr()->to_data<
int>(), i);
286 EXPECT_EQ(it.get_curr()->to_data<
int>(), i);
295 for (
int i = 0, n = 4; i < 3; ++i, ++n, it.
next())
299 list.rotate_left(22);
302 EXPECT_EQ(it.get_curr()->to_data<
int>(), i);
T & insert(const T &item)
Insert 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.
void reset_first() noexcept
bool is_in_last() const noexcept
Return true if the iterator is positioned on the last item.
bool is_last() const noexcept
void next()
Move the iterator one item forward.
Slinknc * get_curr() const
Return the current node on which the iterator is positioned.
bool has_curr() const noexcept
Return true if iterator has current item.
bool is_in_first() const noexcept
Return true if the iterator is positioned on the first item.
Single linked list of nodes.
Slinknc * get_first() const noexcept
Return list first element.
void push(Slinknc *link) noexcept
Insert link as first element.
void remove_all_and_delete() noexcept
Remove and free memory for all the items of list.
Slinknc * get_tail() const noexcept
Return list tail (last element)
size_t reverse() noexcept
It inverts all list elements.
constexpr bool is_empty() const noexcept
Return true if list is empty.
Slinknc * get_head() const noexcept
Return list head (first element)
void rotate_left(size_t n)
Rotate to left the list n positions.
void cut(Slinknc *link, HTList &list) noexcept
It cuts 'this' over 'link' element and it puts all remaining elements.
void append(Slinknc *link) noexcept
Insert link as last element.
size_t split(HTList &l, HTList &r) noexcept
size_t size() const noexcept
Count the number of elements of the list.
void insert(Slinknc *link) noexcept
Insert link as first element.
bool is_unitarian() const noexcept
Return true if the list contains exactly just one element.
Slinknc * get_last() const noexcept
Return the last item of the list (nullptr if the list is empty)
bool is_unitarian_or_empty() const noexcept
Return true if list contains one element or is empty.
Link of a single linked list non-circular and without header node.
Snodenc< T > * to_snodenc() noexcept
Convert this to a Snodenc<T>.
Node belonging to a single non-circular linked list without header node.
T & get_data() noexcept
Return a modifiable reference to the data.
Singly linked list implementations with head-tail access.
TEST_F(List_of_25_nodes, Basic_operations)
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.
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.