48# include <type_traits>
59# define NEXT(p) (p->get_next())
63template <
typename T>
class Snodenc;
169 template <
typename T>
inline
227 return curr !=
nullptr;
238 <<
"Iterator is at the end of the list";
257 <<
"Iterator is at the end of the list";
278 template <
typename T>
295 static_assert(std::is_default_constructible<T>::value,
296 "No default constructor for T");
303 static_assert(std::is_copy_constructible<T>::value,
304 "No copy constructor for T");
312 static_assert(std::is_move_constructible<T>::value,
313 "No move constructor for T");
354 template <
typename T>
inline
360 template <
typename T>
inline
594 NEXT(link) = list.head;
600 list.head = list.tail =
nullptr;
626 <<
"HTList is empty";
660 <<
"Removing from a empty list";
672 prev = p, p =
NEXT(p))
703 <<
"HTList as stack is empty";
710 <<
"HTList as stack is empty";
747 while (q !=
tail and q !=
nullptr)
750 if (q ==
tail or q ==
nullptr)
824 list.head =
NEXT(link);
828 NEXT(link) =
nullptr;
955 <<
"Iterator overflow";
996 <<
"Iterator overflow";
1041 <<
"Iterator overflow";
1100 for (
size_t i = 0; i < n; ++i)
1146 template <
typename T =
int>
1158 using CtorBase::CtorBase;
1192 static_assert(std::is_copy_constructible_v<T>
or
1193 std::is_move_constructible_v<T>,
1194 "No copy assign for T");
1196 return p->get_data();
1201 static_assert(std::is_copy_constructible_v<T>
or
1202 std::is_move_constructible_v<T>,
1203 "No copy assign for T");
1205 return p->get_data();
1258 return push(std::forward<T>(item));
1300 T ret_val = std::move(p->get_data());
1315 T ret_val = std::move(p->get_data());
1463 T
ret_val = std::move(p->get_data());
1482 for (
auto it = this->
get_it(); it.has_curr(); it.next())
1490 template <
class Equal = std::equal_to<T>>
1495 const T & item = it.get_curr_ne();
1529 template <
class Equal = std::equal_to<T>>
T remove(Equal
eq)
1532 if (
const T & item = it.get_curr();
eq(item))
1693template <
class Container>
1702 template <
typename T>
inline
1710 template <
typename T>
inline
Variadic constructor macros for containers.
Container traversal and functional operation mixins.
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error()
Throws std::domain_error unconditionally.
#define ah_underflow_error_if(C)
Throws std::underflow_error if condition holds.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
STL-compatible iterator adapters for Aleph containers.
Standard functor implementations and comparison objects.
Functional programming utilities for Aleph-w containers.
Iterator on the items of list.
Iterator() noexcept=default
The type of container.
T & get_curr() const
Return the current item.
T del()
Remove the current item of the iterator.
T & get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
Dynamic singly linked list with functional programming support.
T & insert(const T &item)
T remove(Equal eq)
Remove the first element matching an equality criteria.
T & get_last_ne() const noexcept
Return the last item of the list without exception.
T & insert(T &&item)
Insert a new item by movement.
DynList(DynList &&l) noexcept
Initialize the list with all the items of l moved to this.
T remove_ne(Equal eq) noexcept
T & append(const T &item)
Slinknc * get_tail() const noexcept=delete
DynList & operator=(const DynList &l)
Assign to this a copy of l
Slinknc * get_head() const noexcept=delete
DynList & append(DynList &&list) noexcept
Append listat the end of this by movement.
T & operator[](const size_t &i)
Array-style access to the i-th item. Equivalent to get(i).
T & get_last() const
Return the last item of the list.
T & get_first() const
Return the first item of the list.
T remove_ne() noexcept
Remove the first item of the list without exception.
DynList reverse() const
Return a reversed copy of this.
T remove()
Remove the first item of the list.
T & __insert(Snodenc< T > *p) noexcept
DynList(const DynList &l)
Initialize a list with a copy of all the items of list l
T & get(const size_t i)
Obtains a modifiable reference to the i-th item of this.
void clear() noexcept
Empties the container.
DynList & insert(const DynList &list)
Insert to this a copy of list.
DynList & insert(DynList &&list) noexcept
Insert listat the beginning of this by movement.
T & __append(Snodenc< T > *p) noexcept
DynList & reverse() noexcept
void empty() noexcept
empty the list
DynList()
Initialize an empty list.
DynList & swap(DynList &l) noexcept
DynList & append(const DynList &list)
Append to this a copy of list.
T remove_first_ne() noexcept
T & get_first_ne() const noexcept
Return the first item of the list without exception.
Slinknc * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
long get_pos() const noexcept
void reset_last()
It has O(n) of performance.
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
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
Slinknc * get_curr() const
Iterator & operator=(const Iterator &it) noexcept
bool has_curr() const noexcept
bool is_in_first() const noexcept
Return true if the iterator is positioned on the first item.
Slinknc * del_ne() noexcept
Iterator() noexcept=default
Iterator(const Iterator &)=default
void end() noexcept
Set the iterator to its end position, which has not.
void reset() noexcept
Reset the iterator at the first item.
Single linked list of nodes.
Slinknc * get_first() const noexcept
void push(Slinknc *link) noexcept
void put(Slinknc *link) noexcept
size_t reverse_list() noexcept
void remove_all_and_delete() noexcept
Slinknc * get_tail() const noexcept
size_t reverse() noexcept
It inverts all list elements. It returns list size.
void insert(HTList &l) noexcept
Insert starting in link (contained in 'this' list) the.
void cut_list(Slinknc *link, HTList &list) noexcept
constexpr bool is_empty() const noexcept
void insert(Slinknc *link, HTList &list) noexcept
Insert a list into this after one of its items.
Slinknc * get_head() const noexcept
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.
void concat_list(HTList &l) noexcept
HTList & swap(HTList &l) noexcept
void append(Slinknc *link) noexcept
size_t split_list(HTList &l, HTList &r) noexcept
It divides 'this' into two equal lists without modifying.
void append(HTList &l) noexcept
Slinknc * remove_first_ne() noexcept
size_t split(HTList &l, HTList &r) noexcept
size_t size() const noexcept
Count the number of elements of the list.
bool remove(Slinknc *link)
void insert(Slinknc *link) noexcept
Slinknc * remove_head_ne() noexcept
It deletes head element (first one). Return deleted.
bool is_unitarian() const noexcept
Return true if the list contains exactly just one.
Slinknc * get_last() const noexcept
Return the last item of the list (nullptr if the list is empty)
size_t split_list_ne(HTList &l, HTList &r) noexcept
void concat(HTList &l) noexcept
Concat to 'this' all 'l' list; 'l' becomes empty.
bool is_unitarian_or_empty() const noexcept
Return true if list contains one element or is empty.
void reset_first() noexcept
Reset the iterator to the first link on the list.
bool has_curr() const noexcept
Return true if the iterator is positioned on a valid link.
Slinknc * get_curr() const
Slinknc * get_curr_ne() const noexcept
Return the current link guaranteeing no exception. Be careful.
Iterator(Slinknc *_head, Slinknc *_curr) noexcept
Initialize an iterator on the list pointed by _head, but on a node pointed by curr
void next_ne() noexcept
Move the iterator one position forward guaranteeing no exception.
Iterator(Slinknc &list) noexcept
Initialize an iterator on the first node of list
Link of a single linked list non-circular and without header node.
virtual ~Slinknc()=default
Slinknc *& get_next() noexcept
void reset() noexcept
Reset the link to nullptr.
Slinknc() noexcept
Init to nullptr.
constexpr bool is_empty() const noexcept
Return true if this is empty.
Slinknc & operator=(const Slinknc &) noexcept
Dummy asignation; link is set to nullptr.
Slinknc(const Slinknc &) noexcept
Dummy copy constructor.
Snodenc< T > * to_snodenc() noexcept
Convert this to a Snodenc<T>.
Slinknc * remove_next() noexcept
void insert(Slinknc *p) noexcept
insert(p) inserts the node pointed by p after this.
Snodenc(T &&item)
Construct by moving item
Snodenc(const T &item)
Construct with copy of item
const T & get_data() const noexcept
Return a constant reference to the data.
Snodenc *& get_next() noexcept
Return the node following to this
Snodenc *& get_first() const noexcept
T & get_data() noexcept
Return a modifiable reference to the data.
Snodenc * remove_next() noexcept
Snodenc * remove_first() noexcept
Mixin providing equality comparison for sequence containers.
Common methods to the Aleph-w ( ) containers.
Common sequential searching methods on containers.
auto get_it() const
Return a properly initialized iterator positioned at the first item on the container.
Mixin that adds STL begin()/end() and cbegin()/cend() to Aleph containers.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
DynList< typename Container::Item_Type > to_dynlist(const Container &c)
bool eq(const C1 &c1, const C2 &c2, Eq e=Eq())
Check equality of two containers using a predicate.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
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.
std::decay_t< typename HeadC::Item_Type > T
DynList< T > unitarian_DynList(const T &item)
bool has_curr() const noexcept
Return true if all underlying iterators are positioned on a valid item.
DynList< T > get_unitarian_DynList(const T &item)
static std::atomic< bool > init
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Generic list of items stored in a container.
Generic traversal of the container through its iterator.
Special constructors common to Aleph-w ( ) containers.