62#include <initializer_list>
64#define GUM_DEFAULT_ITERATOR_NUMBER 4
72#ifndef DOXYGEN_SHOULD_SKIP_THIS
74 template <
typename Val >
76 template <
typename Val >
78 template <
typename Val >
79 class ListConstIterator;
80 template <
typename Val >
81 class ListIteratorSafe;
82 template <
typename Val >
83 class ListConstIteratorSafe;
84 template <
typename Val >
91 template < typename Val >
92 std::ostream&
operator<<(std::ostream& stream,
const List< Val >& list);
113 template <
typename Val >
149 template <
typename... Args >
225 const Val& operator*() const noexcept;
378 template <
typename Val >
432 List(std::initializer_list< Val > list);
455 const const_iterator_safe&
cendSafe() const noexcept;
481 const const_iterator_safe&
crendSafe() const noexcept;
562 const const_iterator&
cend() const noexcept;
591 const const_iterator&
end() const noexcept;
607 const const_iterator&
crend() const noexcept;
639 const const_iterator&
rend() const noexcept;
655 const_iterator
cbegin() const;
686 const_iterator
begin() const;
702 const_iterator
crbegin() const;
734 const_iterator
rbegin() const;
777 template < typename... Args >
789 template < typename... Args >
828 template < typename... Args >
841 template < typename... Args >
853 Val&
insert(const Val& val);
955 template < typename... Args >
971 template < typename... Args >
1002 bool exists(const Val& val) const;
1089 bool empty() const noexcept;
1109 template < typename Mount >
1110 List< Mount >
map(Mount (*f)(Val)) const;
1118 template < typename Mount >
1119 List< Mount >
map(Mount (*f)(Val&)) const;
1127 template < typename Mount >
1128 List< Mount >
map(Mount (*f)(const Val&)) const;
1137 template < typename Mount >
1138 List< Mount >
map(const Mount& mount) const;
1164 List< Val >& operator=(const
List< Val >& src);
1172 List< Val >& operator=(
List< Val >&& src);
1186 Val& operator+=(const Val& val);
1200 Val& operator+=(Val&& val);
1210 bool operator==(const
List< Val >& src) const;
1220 bool operator!=(const
List< Val >& src) const;
1234 Val& operator[](const
Size i);
1248 const Val& operator[](const
Size i) const;
1334 template <
typename... Args >
1449 template <
typename Val >
1475#ifndef DOXYGEN_SHOULD_SKIP_THIS
1526 void clear() noexcept;
1539 bool isEnd() const noexcept;
1653 const Val& operator*() const;
1660 const Val* operator->() const;
1679 template < typename Val >
1736 template < typename Val >
1762#ifndef DOXYGEN_SHOULD_SKIP_THIS
1911 bool operator==(const
ListIterator< Val >& src) const noexcept;
1922 bool operator!=(const
ListIterator< Val >& src) const noexcept;
1929 const Val& operator*() const;
1944 const Val* operator->() const;
2005 template < typename Val >
2031#ifndef DOXYGEN_SHOULD_SKIP_THIS
2210 const Val& operator*() const;
2217 const Val* operator->() const;
2250 void _removeFromSafeList_() const;
2260 template < typename Val >
2318 template < typename Val >
2344#ifndef DOXYGEN_SHOULD_SKIP_THIS
2519 const Val& operator*() const;
2526 const Val* operator->() const;
2529#ifndef DOXYGEN_SHOULD_SKIP_THIS
2541 inline constexpr void*
const _list_end_safe_ = (
void*
const)&_static_list_end_safe_;
2542 inline constexpr void*
const _list_end_ = (
void*
const)&_static_list_end_;
2548#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
Bucket for a chained list.
Val _val_
Val is the value contained in the box.
const ListBucket< Val > * next() const noexcept
Returns the bucket toward the next element.
ListBucket< Val > * _next_
Chaining toward the adjacent elements.
const ListBucket< Val > * previous() const noexcept
Returns the bucket toward the preceding element.
bool operator==(const ListBucket< Val > &src) const
Equality check.
ListBucket< Val > & operator=(const ListBucket< Val > &src)
Copy operator.
ListBucket()=delete
Removes empty constructor.
~ListBucket()
Class destructor.
Val & operator*() noexcept
Dereferencing operator.
Emplace
C dummy type for the emplace constructor.
ListBucket(ListBucket< Val > &&src)=delete
Move constructor should be useless.
ListBucket(Emplace, Args &&... args)
Emplace (universal) constructor.
ListBucket< Val > * _prev_
Chaining toward the adjacent elements.
ListBucket< Val > & operator=(ListBucket< Val > &&src)=delete
Move operator.
bool operator!=(const ListBucket< Val > &src) const
Inequality check.
Safe const iterators for Lists.
Val value_type
Types for STL compliance.
ListBucket< Val > * _bucket_
The bucket in the chained list pointed to by the iterator.
std::ptrdiff_t difference_type
Types for STL compliance.
std::bidirectional_iterator_tag iterator_category
Types for STL compliance.
Val * pointer
Types for STL compliance.
ListBucket< Val > * _next_current_bucket_
The bucket we should start from when we are pointing on a deleted bucket and we decide to do a ++.
ListBucket< Val > * _prev_current_bucket_
The bucket we should start from when we are pointing on a deleted bucket and we decide to do a –.
const Val & const_reference
Types for STL compliance.
ListConstIteratorSafe() noexcept
Default constructor.
const Val * const_pointer
Types for STL compliance.
const List< Val > * _list_
The list the iterator is pointing to.
bool _null_pointing_
Indicates whether the bucket the iterator points to has been deleted.
Val & reference
Types for STL compliance.
Unsafe but fast const iterators for Lists.
const Val * const_pointer
Types for STL compliance.
ListBucket< Val > * _bucket_
The bucket in the chained list pointed to by the iterator.
std::ptrdiff_t difference_type
Types for STL compliance.
Val value_type
Types for STL compliance.
bool isEnd() const noexcept
Returns a bool indicating whether the iterator points to the end of the list.
const Val & const_reference
Types for STL compliance.
ListConstIterator< Val > & operator=(const ListConstIterator< Val > &src) noexcept
Copy operator.
ListBucket< Val > * _getBucket_() const noexcept
Returns the bucket the iterator is pointing to.
std::bidirectional_iterator_tag iterator_category
Types for STL compliance.
void clear() noexcept
Makes the iterator point toward nothing.
~ListConstIterator() noexcept
Class Desctructor.
ListConstIterator() noexcept
Default constructor.
Val & reference
Types for STL compliance.
void setToEnd() noexcept
Positions the iterator to the end of the list.
ListConstIterator< Val > & operator++() noexcept
Makes the iterator point to the next element in the List.
Val * pointer
Types for STL compliance.
Safe iterators for Lists.
Val * pointer
Types for STL compliance.
std::ptrdiff_t difference_type
Types for STL compliance.
Val value_type
Types for STL compliance.
ListIteratorSafe() noexcept
Default constructor.
const Val * const_pointer
Types for STL compliance.
std::bidirectional_iterator_tag iterator_category
Types for STL compliance.
Val & reference
Types for STL compliance.
const Val & const_reference
Types for STL compliance.
Unsafe but fast iterators for Lists.
Val value_type
Types for STL compliance.
const Val * const_pointer
Types for STL compliance.
std::ptrdiff_t difference_type
Types for STL compliance.
std::bidirectional_iterator_tag iterator_category
Types for STL compliance.
Val & reference
Types for STL compliance.
ListIterator() noexcept
Default constructor.
Val * pointer
Types for STL compliance.
const Val & const_reference
Types for STL compliance.
Generic doubly linked lists.
Val & emplaceFront(Args &&... args)
Emplace elements at the beginning of the chained list.
std::vector< const_iterator_safe * > _safe_iterators_
The list of "safe" iterators attached to the list.
void eraseByVal(const Val &val)
erases the first element encountered with a given value.
ListBucket< Val > * _getBucket_(const Val &val) const noexcept
Returns the bucket corresponding to a given value.
const_iterator cbegin() const
Returns an unsafe const iterator pointing to the beginning of the List.
const_iterator crbegin() const
Returns an unsafe const iterator pointing to the last element of the List.
bool exists(const Val &val) const
Checks whether there exists a given element in the list.
const iterator_safe & endSafe() noexcept
Returns a safe iterator pointing to the end of the List.
Val & front() const
Returns a reference to first element of a list, if any.
ListBucket< Val > * _getIthBucket_(Size i) const noexcept
Returns the bucket corresponding to the ith position in the list.
ListConstIteratorSafe< Val > const_iterator_safe
Types for STL compliance.
std::ptrdiff_t difference_type
Types for STL compliance.
friend class ListConstIterator< Val >
ListIterator should be a friend to optimize access to elements.
const const_iterator_safe & crendSafe() const noexcept
Return a safe const iterator pointing just before the beginning of the List.
location
Locations around iterators where insertions of new elements can take / place.
Val & push_front(Args &&... args)
An alias for pushFront used for STL compliance.
Val & pushFront(const Val &val)
Inserts a new element (a copy) at the beginning of the chained list.
List()
A basic constructor that creates an empty list.
Val * pointer
Types for STL compliance.
void popBack()
Removes the last element of a List, if any.
Size size() const noexcept
Returns the number of elements in the list.
void clear()
Deletes all the elements of a chained list.
friend class ListIteratorSafe< Val >
ListIterator should be a friend to optimize access to elements.
friend class ListConstIteratorSafe< Val >
ListIterator should be a friend to optimize access to elements.
std::string toString() const
Converts a list into a string.
ListBucket< Val > * _createEmplaceBucket_(Args &&... args) const
Create an emplace bucket.
bool empty() const noexcept
Returns a boolean indicating whether the chained list is empty.
ListIterator< Val > iterator
Types for STL compliance.
void eraseAllVal(const Val &val)
erases all the elements encountered with a given value
friend class ListIterator< Val >
ListIterator should be a friend to optimize access to elements.
iterator_safe rbeginSafe()
Returns a safe iterator pointing to the last element of the List.
List< Mount > map(Mount(*f)(Val)) const
Creates a list of mountains from a list of val.
void _erase_(ListBucket< Val > *bucket)
Removes an element from a chained list.
iterator rbegin()
Returns an unsafe iterator pointing to the last element of the List.
const iterator & rend() noexcept
Returns an unsafe iterator pointing just before the beginning of the List.
Val & push_back(Args &&... args)
An alias for pushBack used for STL compliance.
const const_iterator & cend() const noexcept
Returns an unsafe const iterator pointing to the end of the List.
const iterator_safe & rendSafe() noexcept
Returns a safe iterator pointing just before the beginning of the List.
void popFront()
Removes the first element of a List, if any.
Val & emplaceBack(Args &&... args)
Emplace elements at the end of the chained list.
const const_iterator & crend() const noexcept
Returns an unsafe const iterator pointing just before the beginning of the List.
Val & _insertBefore_(ListBucket< Val > *new_elt, ListBucket< Val > *current_elt)
Insert a new bucket before another one.
const_iterator_safe crbeginSafe() const
Returns a safe const iterator pointing to the last element of the List.
ListBucket< Val > * _deb_list_
A pointer on the first element of the chained list.
Val value_type
Types for STL compliance.
const Val & const_reference
Types for STL compliance.
const const_iterator_safe & cendSafe() const noexcept
Returns a safe const iterator pointing to the end of the List.
Size size_type
Types for STL compliance.
Val & _insertAfter_(ListBucket< Val > *new_elt, ListBucket< Val > *current_elt)
Insert a new bucket after another one.
ListIteratorSafe< Val > iterator_safe
Types for STL compliance.
const iterator & end() noexcept
Returns an unsafe iterator pointing to the end of the List.
const Val * const_pointer
Types for STL compliance.
iterator_safe beginSafe()
Returns a safe iterator pointing to the beginning of the List.
Val & insert(const Val &val)
Inserts a new element at the end of the chained list (alias of pushBack).
iterator begin()
Returns an unsafe iterator pointing to the beginning of the List.
Size _nb_elements_
The number of elements in the list.
const_iterator_safe cbeginSafe() const
Returns a safe const iterator pointing to the beginning of the List.
void _copy_elements_(const List< Val > &src)
A function used to perform copies of elements of Lists.
Val & pushBack(const Val &val)
Inserts a new element (a copy) at the end of the chained list.
Val & _pushFront_(ListBucket< Val > *new_elt)
Insert a bucket at the front of the list.
Val & emplace(const const_iterator &iter, Args &&... args)
Emplace a new element before a given iterator.
Val & back() const
Returns a reference to last element of a list, if any.
void erase(Size i)
Erases the ith element of the List (the first one is in position 0).
Val & _pushBack_(ListBucket< Val > *new_elt)
Insert a bucket at the end of the list.
Val & _insert_(const const_iterator_safe &iter, ListBucket< Val > *new_elt, location place)
Inserts a new bucket before or after the location pointed to by an iterator.
void swap(List &other_list)
Swap the current list with another one.
ListConstIterator< Val > const_iterator
Types for STL compliance.
ListBucket< Val > * _createBucket_(const Val &val) const
Create a new bucket with a given value.
ListBucket< Val > * _end_list_
A pointer on the last element of the chained list.
Val & reference
Types for STL compliance.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
template implementation of chained lists
gum is the global namespace for all aGrUM entities
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree
Class providing aGrUM's "smart" pointers.
Data types to enable creating static variables at compile time.