![]() |
aGrUM
0.16.0
|
Generic doubly linked lists. More...
#include <agrum/core/list.h>
Public Member Functions | |
template<typename OtherAlloc > | |
INLINE | List (const List< Val, OtherAlloc > &src) |
template<typename OtherAlloc > | |
INLINE List< Val, Alloc > & | operator= (const List< Val, OtherAlloc > &src) |
template<typename... Args> | |
INLINE ListBucket< Val > * | __createEmplaceBucket (Args &&... args) const |
template<typename... Args> | |
INLINE Val & | push_front (Args &&... args) |
template<typename... Args> | |
INLINE Val & | emplaceFront (Args &&... args) |
template<typename... Args> | |
INLINE Val & | push_back (Args &&... args) |
template<typename... Args> | |
INLINE Val & | emplaceBack (Args &&... args) |
template<typename... Args> | |
INLINE Val & | emplace (const const_iterator &iter, Args &&... args) |
template<typename... Args> | |
INLINE Val & | emplace (const const_iterator_safe &iter, Args &&... args) |
template<typename OtherAlloc > | |
INLINE bool | operator== (const List< Val, OtherAlloc > &src) const |
template<typename OtherAlloc > | |
INLINE bool | operator!= (const List< Val, OtherAlloc > &src) const |
Constructors / Destructors | |
List () | |
A basic constructor that creates an empty list. More... | |
List (const List< Val, Alloc > &src) | |
Copy constructor. More... | |
template<typename OtherAlloc > | |
List (const List< Val, OtherAlloc > &src) | |
Ceneralized copy constructor. More... | |
List (List< Val, Alloc > &&src) | |
Move constructor. More... | |
List (std::initializer_list< Val > list) | |
Initializer_list constructor. More... | |
~List () | |
Class destructor. More... | |
Iterators | |
const const_iterator_safe & | cendSafe () const noexcept |
Returns a safe const iterator pointing to the end of the List. More... | |
const iterator_safe & | endSafe () noexcept |
Returns a safe iterator pointing to the end of the List. More... | |
const const_iterator_safe & | crendSafe () const noexcept |
Return a safe const iterator pointing just before the beginning of the List. More... | |
const iterator_safe & | rendSafe () noexcept |
Returns a safe iterator pointing just before the beginning of the List. More... | |
const_iterator_safe | cbeginSafe () const |
Returns a safe const iterator pointing to the beginning of the List. More... | |
iterator_safe | beginSafe () |
Returns a safe iterator pointing to the beginning of the List. More... | |
const_iterator_safe | crbeginSafe () const |
Returns a safe const iterator pointing to the last element of the List. More... | |
iterator_safe | rbeginSafe () |
Returns a safe iterator pointing to the last element of the List. More... | |
const const_iterator & | cend () const noexcept |
Returns an unsafe const iterator pointing to the end of the List. More... | |
const iterator & | end () noexcept |
Returns an unsafe iterator pointing to the end of the List. More... | |
const const_iterator & | end () const noexcept |
Returns an unsafe const iterator pointing to the end of the List. More... | |
const const_iterator & | crend () const noexcept |
Returns an unsafe const iterator pointing just before the beginning of the List. More... | |
const iterator & | rend () noexcept |
Returns an unsafe iterator pointing just before the beginning of the List. More... | |
const const_iterator & | rend () const noexcept |
Returns an unsafe const iterator pointing just before the beginning of the List. More... | |
const_iterator | cbegin () const |
Returns an unsafe const iterator pointing to the beginning of the List. More... | |
iterator | begin () |
Returns an unsafe iterator pointing to the beginning of the List. More... | |
const_iterator | begin () const |
Returns an unsafe const iterator pointing to the beginning of the List. More... | |
const_iterator | crbegin () const |
Returns an unsafe const iterator pointing to the last element of the List. More... | |
iterator | rbegin () |
Returns an unsafe iterator pointing to the last element of the List. More... | |
const_iterator | rbegin () const |
Returns an unsafe const iterator pointing to the last element of the List. More... | |
Accessors / Modifiers | |
Val & | pushFront (const Val &val) |
Inserts a new element (a copy) at the beginning of the chained list. More... | |
Val & | pushFront (Val &&val) |
Inserts a new element (a move) at the beginning of the chained list. More... | |
template<typename... Args> | |
Val & | push_front (Args &&... args) |
An alias for pushFront used for STL compliance. More... | |
template<typename... Args> | |
Val & | emplaceFront (Args &&... args) |
Emplace elements at the beginning of the chained list. More... | |
Val & | pushBack (const Val &val) |
Inserts a new element (a copy) at the end of the chained list. More... | |
Val & | pushBack (Val &&val) |
Inserts a new element (a move) at the end of the chained list. More... | |
template<typename... Args> | |
Val & | push_back (Args &&... args) |
An alias for pushBack used for STL compliance. More... | |
template<typename... Args> | |
Val & | emplaceBack (Args &&... args) |
Emplace elements at the end of the chained list. More... | |
Val & | insert (const Val &val) |
Inserts a new element at the end of the chained list (alias of pushBack). More... | |
Val & | insert (Val &&val) |
Inserts a new element at the end of the chained list (alias of pushBack). More... | |
Val & | insert (Size pos, const Val &val) |
Inserts a new element at the ith pos of the chained list. More... | |
Val & | insert (Size pos, Val &&val) |
Insert an rvalue at the ith pos of the chained list. More... | |
Val & | insert (const const_iterator_safe &iter, const Val &val, location place=location::BEFORE) |
Inserts a new element before or after a given iterator. More... | |
Val & | insert (const const_iterator_safe &iter, Val &&val, location place=location::BEFORE) |
Inserts an rvalue before or after a given iterator. More... | |
Val & | insert (const const_iterator &iter, const Val &val, location place=location::BEFORE) |
Inserts a new element before or after a given iterator. More... | |
Val & | insert (const const_iterator &iter, Val &&val, location place=location::BEFORE) |
Inserts an rvalue before or after a given iterator. More... | |
template<typename... Args> | |
Val & | emplace (const const_iterator &iter, Args &&... args) |
Emplace a new element before a given iterator. More... | |
template<typename... Args> | |
Val & | emplace (const const_iterator_safe &iter, Args &&... args) |
Emplace a new element before a given safe iterator. More... | |
Val & | front () const |
Returns a reference to first element of a list, if any. More... | |
Val & | back () const |
Returns a reference to last element of a list, if any. More... | |
Size | size () const noexcept |
Returns the number of elements in the list. More... | |
bool | exists (const Val &val) const |
Checks whether there exists a given element in the list. More... | |
void | erase (Size i) |
Erases the ith element of the List (the first one is in position 0). More... | |
void | erase (const iterator_safe &iter) |
Erases the element of the List pointed to by the safe iterator. More... | |
void | erase (const const_iterator_safe &iter) |
Erases the element of the List pointed to by the safe const iterator. More... | |
void | eraseByVal (const Val &val) |
erases the first element encountered with a given value. More... | |
void | eraseAllVal (const Val &val) |
erases all the elements encountered with a given value More... | |
void | popBack () |
Removes the last element of a List, if any. More... | |
void | popFront () |
Removes the first element of a List, if any. More... | |
void | clear () |
Deletes all the elements of a chained list. More... | |
bool | empty () const noexcept |
Returns a boolean indicating whether the chained list is empty. More... | |
void | swap (List &other_list) |
Swap the current list with another one. More... | |
std::string | toString () const |
Converts a list into a string. More... | |
template<typename Mount , typename OtherAlloc = std::allocator< Mount >> | |
List< Mount, OtherAlloc > | map (Mount(*f)(Val)) const |
Creates a list of mountains from a list of val. More... | |
template<typename Mount , typename OtherAlloc = std::allocator< Mount >> | |
List< Mount, OtherAlloc > | map (Mount(*f)(Val &)) const |
Creates a list of mountains from a list of val. More... | |
template<typename Mount , typename OtherAlloc = std::allocator< Mount >> | |
List< Mount, OtherAlloc > | map (Mount(*f)(const Val &)) const |
Creates a list of mountains from a list of val. More... | |
template<typename Mount , typename OtherAlloc = std::allocator< Mount >> | |
List< Mount, OtherAlloc > | map (const Mount &mount) const |
Creates a list of mountains with a given value from a list of val. More... | |
Operators | |
List< Val, Alloc > & | operator= (const List< Val, Alloc > &src) |
Copy operator. More... | |
template<typename OtherAlloc > | |
List< Val, Alloc > & | operator= (const List< Val, OtherAlloc > &src) |
Generalized copy operator. More... | |
List< Val, Alloc > & | operator= (List< Val, Alloc > &&src) |
Move operator. More... | |
Val & | operator+= (const Val &val) |
Inserts a new element at the end of the list (alias of pushBack). More... | |
Val & | operator+= (Val &&val) |
Inserts a new element at the end of the list (alias of pushBack). More... | |
template<typename OtherAlloc > | |
bool | operator== (const List< Val, OtherAlloc > &src) const |
Checks whether two lists are identical (same elements in the same order). More... | |
template<typename OtherAlloc > | |
bool | operator!= (const List< Val, OtherAlloc > &src) const |
Checks whether two lists are different (different elements or orders). More... | |
Val & | operator[] (const Size i) |
Returns the ith element in the current chained list. More... | |
const Val & | operator[] (const Size i) const |
Returns the const ith element in the current chained list. More... | |
Public Types | |
enum | location { location::BEFORE, location::AFTER } |
Locations around iterators where insertions of new elements can take / place. More... | |
using | BucketAllocator = typename Alloc::template rebind< ListBucket< Val > >::other |
Type of the allocator for ListBuckets. More... | |
using | value_type = Val |
Types for STL compliance. More... | |
using | reference = Val & |
Types for STL compliance. More... | |
using | const_reference = const Val & |
Types for STL compliance. More... | |
using | pointer = Val * |
Types for STL compliance. More... | |
using | const_pointer = const Val * |
Types for STL compliance. More... | |
using | size_type = Size |
Types for STL compliance. More... | |
using | difference_type = std::ptrdiff_t |
Types for STL compliance. More... | |
using | allocator_type = Alloc |
Types for STL compliance. More... | |
using | iterator = ListIterator< Val > |
Types for STL compliance. More... | |
using | const_iterator = ListConstIterator< Val > |
Types for STL compliance. More... | |
using | iterator_safe = ListIteratorSafe< Val > |
Types for STL compliance. More... | |
using | const_iterator_safe = ListConstIteratorSafe< Val > |
Types for STL compliance. More... | |
Friends | |
class | ListIterator< Val > |
ListIterator should be a friend to optimize access to elements. More... | |
class | ListConstIterator< Val > |
ListIterator should be a friend to optimize access to elements. More... | |
class | ListIteratorSafe< Val > |
ListIterator should be a friend to optimize access to elements. More... | |
class | ListConstIteratorSafe< Val > |
ListIterator should be a friend to optimize access to elements. More... | |
Generic doubly linked lists.
List enables fast and safe manipulation of chained lists. Unless the elements are rvalues, the insertions of new elements into the lists are ALWAYS performed by copy, i.e., each time we add a new element X to the List, a copy of X is actually created and this very copy is stored into the list. For rvalues, move operations are performed.
The List iterators are implemented so as to avoid segmentation faults when elements of the list are deleted while some safe iterators are pointing on them. Moreover they ensure that, when elements are removed from a List, iterators on that list will never access these elements (which is not the case for the iterators in the C++ standard library). Note that this guarantee is ensured at low cost as experimental results show that List and ListIterator are as efficient as their STL counterparts. However, this guarantee can hold only if List is aware of all of the iterators pointing to it: thus, when List erases one element, it can parse the list of its iterators and update those that point toward the now deleted element. When parsing elements without removing any element, you can use unsafe iterators instead of safe ones because they are slightly faster. But those will most certainly segfault if they perform some operations on deleted elements.
using gum::List< Val, Alloc >::allocator_type = Alloc |
using gum::List< Val, Alloc >::BucketAllocator = typename Alloc::template rebind< ListBucket< Val > >::other |
using gum::List< Val, Alloc >::const_iterator = ListConstIterator< Val > |
using gum::List< Val, Alloc >::const_iterator_safe = ListConstIteratorSafe< Val > |
using gum::List< Val, Alloc >::const_pointer = const Val* |
using gum::List< Val, Alloc >::const_reference = const Val& |
using gum::List< Val, Alloc >::difference_type = std::ptrdiff_t |
using gum::List< Val, Alloc >::iterator = ListIterator< Val > |
using gum::List< Val, Alloc >::iterator_safe = ListIteratorSafe< Val > |
using gum::List< Val, Alloc >::value_type = Val |
|
strong |
A basic constructor that creates an empty list.
Definition at line 1186 of file list_tpl.h.
INLINE gum::List< Val, Alloc >::List | ( | const List< Val, Alloc > & | src | ) |
Copy constructor.
The new list and that which is copied do not share their elements: the new list contains new instances of the values stored in the list to be copied. Of course if these values are pointers, the new values point toward the same elements. This constructor runs in linear time.
src | the list the contents of which is copied into the current one. |
Definition at line 1196 of file list_tpl.h.
gum::List< Val, Alloc >::List | ( | const List< Val, OtherAlloc > & | src | ) |
Ceneralized copy constructor.
The new list and that which is copied do not share their elements: the new list contains new instances of the values stored in the list to be copied. Of course if these values are pointers, the new values point toward the same elements. This constructor runs in linear time.
src | the list the contents of which is copied into the current one. |
OtherAlloc | The other allocator. |
INLINE gum::List< Val, Alloc >::List | ( | List< Val, Alloc > && | src | ) |
Move constructor.
src | The gum::List to move. |
Definition at line 1223 of file list_tpl.h.
INLINE gum::List< Val, Alloc >::List | ( | std::initializer_list< Val > | list | ) |
Initializer_list constructor.
list | The initializer list. |
Definition at line 1239 of file list_tpl.h.
INLINE gum::List< Val, Alloc >::List | ( | const List< Val, OtherAlloc > & | src | ) |
Definition at line 1210 of file list_tpl.h.
|
private |
A function used to perform copies of elements of Lists.
Before performing the copy, we assume in this function that the current list (this) is empty (else there would be memory leak).
OtherAlloc | The other allocator. |
src | The gum::List to copy. |
Definition at line 1114 of file list_tpl.h.
|
private |
Create a new bucket with a given value.
val | The value of the new bucket. |
Definition at line 1475 of file list_tpl.h.
|
private |
Create a new bucket with a given value.
val | The value of the new bucket. |
Definition at line 1491 of file list_tpl.h.
|
private |
Create an emplace bucket.
Args | The emplace arguments types. |
args | The emplace arguments. |
INLINE ListBucket< Val >* gum::List< Val, Alloc >::__createEmplaceBucket | ( | Args &&... | args | ) | const |
Definition at line 1509 of file list_tpl.h.
|
private |
Removes an element from a chained list.
If parameter bucket is equal to 0, then the method does not perform anything, else the bucket is deleted. In the latter case, no test is ever performed to check that the bucket does actually belong to the List. The method runs in constant time.
bucket | A pointer on the bucket in the chained list we wish to remove. |
Definition at line 1866 of file list_tpl.h.
|
privatenoexcept |
Returns the bucket corresponding to a given value.
Actually, this is the first bucket of value val encountered in the list, if any, that is returned. If the element cannot be found, 0 is returned. This method enables fast removals of buckets. It runs in linear time.
Comparisons between Val instances are performed through == operators.
val | The value of the element the bucket of which we wish to return. |
Definition at line 1930 of file list_tpl.h.
|
privatenoexcept |
Returns the bucket corresponding to the ith position in the list.
This method assumes that the list contains at least i+1 elements. The index of the first element of the list is 0.
i | The position of the returned element. |
Definition at line 1631 of file list_tpl.h.
|
private |
Inserts a new bucket before or after the location pointed to by an iterator.
iter | An iterator pointing where to insert a new element. |
new_elt | The new element ot insert in the gum::List. |
place | Where to insert the new element relatively to the iterator. |
Definition at line 1706 of file list_tpl.h.
|
private |
Inserts a new bucket before or after the location pointed to by an iterator.
iter | An iterator pointing where to insert a new element. |
new_elt | The new element ot insert in the gum::List. |
place | Where to insert the new element relatively to the iterator. |
Definition at line 1740 of file list_tpl.h.
|
private |
Insert a new bucket after another one.
new_elt | The new element to insert in the gum::List. |
current_elt | The element before which new_elt will be inserted. |
Definition at line 1667 of file list_tpl.h.
|
private |
Insert a new bucket before another one.
new_elt | The new element to insert in the gum::List. |
current_elt | The element before which new_elt will be inserted. |
Definition at line 1647 of file list_tpl.h.
|
private |
Insert a bucket at the end of the list.
new_elt | The new element pushed at the end of the gum::List. |
Definition at line 1546 of file list_tpl.h.
|
private |
Insert a bucket at the front of the list.
new_elt | The new element pushed at the front of the gum::List. |
Definition at line 1527 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::back | ( | ) | const |
Returns a reference to last element of a list, if any.
NotFound | exception is thrown if the list is empty. |
Definition at line 1841 of file list_tpl.h.
INLINE ListIterator< Val > gum::List< Val, Alloc >::begin | ( | ) |
Returns an unsafe iterator pointing to the beginning of the List.
Unsafe iterators are a little bit faster than safe iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Definition at line 1417 of file list_tpl.h.
INLINE ListConstIterator< Val > gum::List< Val, Alloc >::begin | ( | ) | const |
Returns an unsafe const iterator pointing to the beginning of the List.
Unsafe const iterators are a little bit faster than safe const iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Returns an unsafe const iterator pointing to the beginning of the List.
Definition at line 1423 of file list_tpl.h.
INLINE ListIteratorSafe< Val > gum::List< Val, Alloc >::beginSafe | ( | ) |
Returns a safe iterator pointing to the beginning of the List.
Safe iterators are iterators whose state is updated by the list when the element they point to is erased. As such, in this case, they can throw an exception when we try to derefence them and they are able to perform a valid ++ or – step.
Definition at line 1405 of file list_tpl.h.
INLINE ListConstIterator< Val > gum::List< Val, Alloc >::cbegin | ( | ) | const |
Returns an unsafe const iterator pointing to the beginning of the List.
Unsafe const iterators are a little bit faster than safe const iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Definition at line 1411 of file list_tpl.h.
INLINE ListConstIteratorSafe< Val > gum::List< Val, Alloc >::cbeginSafe | ( | ) | const |
Returns a safe const iterator pointing to the beginning of the List.
Safe const iterators are const iterators whose state is updated by the list when the element they point to is erased. As such, in this case, they can throw an exception when we try to derefence them and they are able to perform a valid ++ or – step.
Definition at line 1399 of file list_tpl.h.
|
noexcept |
Returns an unsafe const iterator pointing to the end of the List.
Unsafe const iterators are a little bit faster than safe const iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Returns an unsafe const iterator pointing to the end of the List.
Definition at line 1346 of file list_tpl.h.
|
noexcept |
Returns a safe const iterator pointing to the end of the List.
Safe const iterators are const iterators whose state is updated by the list when the element they point to is erased. As such, in this case, they can throw an exception when we try to derefence them and they are able to perform a valid ++ or – step
Returns a safe const iterator pointing to the end of the List.
Definition at line 1332 of file list_tpl.h.
void gum::List< Val, Alloc >::clear | ( | ) |
Deletes all the elements of a chained list.
All the iterators of the list will be resetted to rend. The method runs in linear time of both the size of the list and the number of iterators attached to the List.
Definition at line 1164 of file list_tpl.h.
INLINE ListConstIterator< Val > gum::List< Val, Alloc >::crbegin | ( | ) | const |
Returns an unsafe const iterator pointing to the last element of the List.
Unsafe iterators are a little bit faster than safe iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Definition at line 1447 of file list_tpl.h.
INLINE ListConstIteratorSafe< Val > gum::List< Val, Alloc >::crbeginSafe | ( | ) | const |
Returns a safe const iterator pointing to the last element of the List.
Safe const iterators are const iterators whose state is updated by the list when the element they point to is erased. As such, in this case, they can throw an exception when we try to derefence them and they are able to perform a valid ++ or – step.
Definition at line 1429 of file list_tpl.h.
|
noexcept |
Returns an unsafe const iterator pointing just before the beginning of the List.
Unsafe const iterators are a little bit faster than safe const iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Definition at line 1379 of file list_tpl.h.
|
noexcept |
Return a safe const iterator pointing just before the beginning of the List.
Safe const iterators are const iterators whose state is updated by the list when the element they point to is erased. As such, in this case, they can throw an exception when we try to derefence them and they are able to perform a valid ++ or – step.
Return a safe const iterator pointing just before the beginning of the List.
Definition at line 1365 of file list_tpl.h.
Val& gum::List< Val, Alloc >::emplace | ( | const const_iterator & | iter, |
Args &&... | args | ||
) |
Emplace a new element before a given iterator.
Emplace is a method that allows to construct directly an element of type Val by passing to its constructor all the arguments it needs. The first element of the list is at pos 0. After the insert, the element is placed precisely at pos if pos is less than the size of the list before insertion, else it is inserted at the end of the list.
iter | The position in the list |
args | The arguments passed to the constructor |
Val& gum::List< Val, Alloc >::emplace | ( | const const_iterator_safe & | iter, |
Args &&... | args | ||
) |
Emplace a new element before a given safe iterator.
Emplace is a method that allows to construct directly an element of type Val by passing to its constructor all the arguments it needs. The first element of the list is at pos 0. After the insert, the element is placed precisely at pos if pos is less than the size of the list before insertion, else it is inserted at the end of the list.
iter | The position in the list. |
args | the arguments passed to the constructor. |
INLINE Val& gum::List< Val, Alloc >::emplace | ( | const const_iterator & | iter, |
Args &&... | args | ||
) |
Definition at line 1812 of file list_tpl.h.
INLINE Val& gum::List< Val, Alloc >::emplace | ( | const const_iterator_safe & | iter, |
Args &&... | args | ||
) |
Definition at line 1822 of file list_tpl.h.
Val& gum::List< Val, Alloc >::emplaceBack | ( | Args &&... | args | ) |
Emplace elements at the end of the chained list.
Emplace is a method that allows to construct directly an element of type Val by passing to its constructor all the arguments it needs
Args | The emplaced arguments types. |
args | The arguments passed to the constructor |
INLINE Val& gum::List< Val, Alloc >::emplaceBack | ( | Args &&... | args | ) |
Definition at line 1612 of file list_tpl.h.
Val& gum::List< Val, Alloc >::emplaceFront | ( | Args &&... | args | ) |
Emplace elements at the beginning of the chained list.
Emplace is a method that allows to construct directly an element of type Val by passing to its constructor all the arguments it needs
args | The arguments passed to the constructor. |
INLINE Val& gum::List< Val, Alloc >::emplaceFront | ( | Args &&... | args | ) |
Definition at line 1586 of file list_tpl.h.
|
noexcept |
Returns a boolean indicating whether the chained list is empty.
Definition at line 1970 of file list_tpl.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesDownward(), gum::learning::Miic::__existsDirectedPath(), gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::BarrenNodesFinder::barrenNodes(), gum::ArcGraphPart::directedPath(), gum::ArcGraphPart::directedUnorientedPath(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::DiGraph::hasDirectedPath(), gum::UndiGraph::hasUndirectedCycle(), gum::MixedGraph::mixedOrientedPath(), gum::MixedGraph::mixedUnorientedPath(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::DAGCycleDetector::setDAG(), and gum::EdgeGraphPart::undirectedPath().
|
noexcept |
Returns an unsafe iterator pointing to the end of the List.
Unsafe iterators are a little bit faster than safe iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Definition at line 1353 of file list_tpl.h.
|
noexcept |
Returns an unsafe const iterator pointing to the end of the List.
Unsafe const iterators are a little bit faster than safe const iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Definition at line 1359 of file list_tpl.h.
|
noexcept |
Returns a safe iterator pointing to the end of the List.
Safe iterators are iterators whose state is updated by the list when the element they point to is erased. As such, in this case, they can throw an exception when we try to derefence them and they are able to perform a valid ++ or – step.
Ceturns a safe iterator pointing to the end of the List.
Definition at line 1340 of file list_tpl.h.
Erases the ith element of the List (the first one is in position 0).
If the element cannot be found, the function returns without throwing any exception. It runs in linear time in the size of the list.
i | The position in the list of the element we wish to remove. |
Definition at line 1909 of file list_tpl.h.
Referenced by gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances().
INLINE void gum::List< Val, Alloc >::erase | ( | const iterator_safe & | iter | ) |
Erases the element of the List pointed to by the safe iterator.
If the element cannot be found, i.e., it has already been erased or the iterator points to end/rend, the function returns without throwing any exception. It runs in linear time in the size of the list.
iter | An iterator pointing to the element to remove. |
Definition at line 1918 of file list_tpl.h.
INLINE void gum::List< Val, Alloc >::erase | ( | const const_iterator_safe & | iter | ) |
Erases the element of the List pointed to by the safe const iterator.
If the element cannot be found, i.e., it has already been erased or the iterator points to end/rend, the function returns without throwing any exception. It runs in linear time in the size of the list.
iter | An iterator pointing to the element to remove. |
Definition at line 1924 of file list_tpl.h.
INLINE void gum::List< Val, Alloc >::eraseAllVal | ( | const Val & | val | ) |
erases all the elements encountered with a given value
If no element equal to val can be found, the function returns without throwing any exception.
Comparisons between Val instances are performed through == operators.
val | the value of the element we wish to remove. |
Definition at line 1946 of file list_tpl.h.
INLINE void gum::List< Val, Alloc >::eraseByVal | ( | const Val & | val | ) |
erases the first element encountered with a given value.
If no element equal to val can be found, the function returns without throwing any exception. It runs in linear time both in the size of the list and in the number of iterators referenced in the list. Comparisons between Val instances are performed through == operators.
val | The value of the element we wish to remove. |
Definition at line 1940 of file list_tpl.h.
INLINE bool gum::List< Val, Alloc >::exists | ( | const Val & | val | ) | const |
Checks whether there exists a given element in the list.
This method runs in linear time.
Comparisons between Val instances are performed through == operators.
val | the value of the element we wish to check the existence of. |
Definition at line 1857 of file list_tpl.h.
Referenced by gum::EssentialGraph::toDot(), gum::UndiGraph::toDot(), and gum::MixedGraph::toDot().
INLINE Val & gum::List< Val, Alloc >::front | ( | ) | const |
Returns a reference to first element of a list, if any.
NotFound | exception is thrown if the list is empty. |
Definition at line 1831 of file list_tpl.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesDownward(), gum::learning::Miic::__existsDirectedPath(), gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::BarrenNodesFinder::barrenNodes(), gum::ArcGraphPart::directedPath(), gum::ArcGraphPart::directedUnorientedPath(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::DiGraph::hasDirectedPath(), gum::UndiGraph::hasUndirectedCycle(), gum::MixedGraph::mixedOrientedPath(), gum::MixedGraph::mixedUnorientedPath(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::DAGCycleDetector::setDAG(), and gum::EdgeGraphPart::undirectedPath().
INLINE Val & gum::List< Val, Alloc >::insert | ( | const Val & | val | ) |
Inserts a new element at the end of the chained list (alias of pushBack).
val | The value inserted. |
Definition at line 1619 of file list_tpl.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesUpward(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesUpward(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__elimination_cost(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__insertEvidence(), gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), gum::BarrenNodesFinder::barrenNodes(), gum::UndiGraph::hasUndirectedCycle(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::DAGCycleDetector::setDAG(), gum::EssentialGraph::toDot(), gum::UndiGraph::toDot(), and gum::MixedGraph::toDot().
INLINE Val & gum::List< Val, Alloc >::insert | ( | Val && | val | ) |
Inserts a new element at the end of the chained list (alias of pushBack).
val | The value inserted. |
Definition at line 1625 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::insert | ( | Size | pos, |
const Val & | val | ||
) |
Inserts a new element at the ith pos of the chained list.
The first element of the list is at pos 0. After the insert, the element is placed precisely at pos if pos is less than the size of the list before insertion, else it is inserted at the end of the list.
pos | The position where to inser the new element. |
val | The value to insert. |
Definition at line 1687 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::insert | ( | Size | pos, |
Val && | val | ||
) |
Insert an rvalue at the ith pos of the chained list.
The first element of the list is at pos 0. After the insert, the element is placed precisely at pos if pos is less than the size of the list before insertion, else it is inserted at the end of the list.
pos | The position where to inser the new element. |
val | The value to insert. |
Definition at line 1696 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::insert | ( | const const_iterator_safe & | iter, |
const Val & | val, | ||
location | place = location::BEFORE |
||
) |
Inserts a new element before or after a given iterator.
iter | The iterator pointing where to inser the new element. |
val | The value to insert. |
place | Defines where to insert the new element relatively to iter. |
Definition at line 1764 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::insert | ( | const const_iterator_safe & | iter, |
Val && | val, | ||
location | place = location::BEFORE |
||
) |
Inserts an rvalue before or after a given iterator.
iter | The iterator pointing where to inser the new element. |
val | The value to insert. |
place | Defines where to insert the new element relatively to iter. |
Definition at line 1779 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::insert | ( | const const_iterator & | iter, |
const Val & | val, | ||
location | place = location::BEFORE |
||
) |
Inserts a new element before or after a given iterator.
iter | The iterator pointing where to inser the new element. |
val | The value to insert. |
place | Defines where to insert the new element relatively to iter. |
Definition at line 1794 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::insert | ( | const const_iterator & | iter, |
Val && | val, | ||
location | place = location::BEFORE |
||
) |
Inserts an rvalue before or after a given iterator.
iter | The iterator pointing where to inser the new element. |
val | The value to insert. |
place | Defines where to insert the new element relatively to iter. |
Definition at line 1803 of file list_tpl.h.
List< Mount, OtherAlloc > gum::List< Val, Alloc >::map | ( | Mount(*)(Val) | f | ) | const |
Creates a list of mountains from a list of val.
f | A function that maps any Val element into a Mount |
Mount | The type of mountains. |
OtherAlloc | The mountains type allocator. |
Definition at line 1996 of file list_tpl.h.
List< Mount, OtherAlloc > gum::List< Val, Alloc >::map | ( | Mount(*)(Val &) | f | ) | const |
Creates a list of mountains from a list of val.
f | A function that maps any Val element into a Mount |
Mount | The type of mountains. |
OtherAlloc | The mountains type allocator. |
Definition at line 2011 of file list_tpl.h.
List< Mount, OtherAlloc > gum::List< Val, Alloc >::map | ( | Mount(*)(const Val &) | f | ) | const |
Creates a list of mountains from a list of val.
f | A function that maps any Val element into a Mount |
Mount | The type of mountains. |
OtherAlloc | The mountains type allocator. |
Definition at line 2026 of file list_tpl.h.
List< Mount, OtherAlloc > gum::List< Val, Alloc >::map | ( | const Mount & | mount | ) | const |
Creates a list of mountains with a given value from a list of val.
mount | the value taken by all the elements of the resulting list |
Mount | The type of mountains. |
OtherAlloc | The mountains type allocator. |
Definition at line 2041 of file list_tpl.h.
bool gum::List< Val, Alloc >::operator!= | ( | const List< Val, OtherAlloc > & | src | ) | const |
Checks whether two lists are different (different elements or orders).
This method runs in time linear in the number of elements of the list.
OtherAlloc | The other allocator. |
INLINE bool gum::List< Val, Alloc >::operator!= | ( | const List< Val, OtherAlloc > & | src | ) | const |
Definition at line 2087 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::operator+= | ( | const Val & | val | ) |
Inserts a new element at the end of the list (alias of pushBack).
This enables writing code like list
+=
xxx
; to add element xxx
to the list.
val | Tha value inserted int the list. |
Definition at line 2055 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::operator+= | ( | Val && | val | ) |
Inserts a new element at the end of the list (alias of pushBack).
This enables writing code like list
+=
xxx
; to add element xxx
to the list.
val | Tha value inserted int the list. |
Definition at line 2062 of file list_tpl.h.
INLINE List< Val, Alloc > & gum::List< Val, Alloc >::operator= | ( | const List< Val, Alloc > & | src | ) |
Copy operator.
The new list and that which is copied do not share the elements: the new list contains new instances of the values stored in the list to be copied. Of course if these values are pointers, the new values point toward the same elements. The List on which the operator is applied keeps its iterator's list. Of course, if it previously contained some elements, those are removed prior to the copy. This operator runs in linear time.
src | the list the content of which will be copied into the current List. |
Definition at line 1266 of file list_tpl.h.
List< Val, Alloc >& gum::List< Val, Alloc >::operator= | ( | const List< Val, OtherAlloc > & | src | ) |
Generalized copy operator.
The new list and that which is copied do not share the elements: the new list contains new instances of the values stored in the list to be copied. Of course if these values are pointers, the new values point toward the same elements. The List on which the operator is applied keeps its iterator's list. Of course, if it previously contained some elements, those are removed prior to the copy. This operator runs in linear time.
src | the list the content of which will be copied into the current List. |
INLINE List< Val, Alloc > & gum::List< Val, Alloc >::operator= | ( | List< Val, Alloc > && | src | ) |
Move operator.
src | The gum::List to move. |
Definition at line 1305 of file list_tpl.h.
INLINE List< Val, Alloc >& gum::List< Val, Alloc >::operator= | ( | const List< Val, OtherAlloc > & | src | ) |
Definition at line 1286 of file list_tpl.h.
bool gum::List< Val, Alloc >::operator== | ( | const List< Val, OtherAlloc > & | src | ) | const |
Checks whether two lists are identical (same elements in the same order).
This method runs in time linear in the number of elements of the list.
OtherAlloc | The other allocator. |
INLINE bool gum::List< Val, Alloc >::operator== | ( | const List< Val, OtherAlloc > & | src | ) | const |
Definition at line 2070 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::operator[] | ( | const Size | i | ) |
Returns the ith element in the current chained list.
The first of the list element has index 0.
This method runs in linear time.
i | The position of the element in the list (0 = first element). |
NotFound | Raised if the element to be retrieved does not exist. |
Definition at line 2093 of file list_tpl.h.
INLINE const Val & gum::List< Val, Alloc >::operator[] | ( | const Size | i | ) | const |
Returns the const ith element in the current chained list.
The first of the list element has index 0.
This method runs in linear time.
i | the position of the element in the list (0 = first element). |
NotFound | Raised if the element to be retrieved does not exist. |
Definition at line 2104 of file list_tpl.h.
INLINE void gum::List< Val, Alloc >::popBack | ( | ) |
Removes the last element of a List, if any.
When the list is empty, it does not do anything.
Definition at line 1958 of file list_tpl.h.
INLINE void gum::List< Val, Alloc >::popFront | ( | ) |
Removes the first element of a List, if any.
When the list is empty, it does not do anything.
Definition at line 1964 of file list_tpl.h.
Referenced by gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesDownward(), gum::learning::Miic::__existsDirectedPath(), gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::BarrenNodesFinder::barrenNodes(), gum::ArcGraphPart::directedPath(), gum::ArcGraphPart::directedUnorientedPath(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::DiGraph::hasDirectedPath(), gum::UndiGraph::hasUndirectedCycle(), gum::MixedGraph::mixedOrientedPath(), gum::MixedGraph::mixedUnorientedPath(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::DAGCycleDetector::setDAG(), and gum::EdgeGraphPart::undirectedPath().
Val& gum::List< Val, Alloc >::push_back | ( | Args &&... | args | ) |
An alias for pushBack used for STL compliance.
Defining push_back allows using, for instance, BackInserters.
Args | The emplace arguments type. |
args | The emplace arguments values. |
Referenced by gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), and gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances().
INLINE Val& gum::List< Val, Alloc >::push_back | ( | Args &&... | args | ) |
Definition at line 1605 of file list_tpl.h.
Val& gum::List< Val, Alloc >::push_front | ( | Args &&... | args | ) |
An alias for pushFront used for STL compliance.
Defining push_front allows using, for instance, FrontInserters.
Args | The emplace values type. |
args | The emplace values. |
INLINE Val& gum::List< Val, Alloc >::push_front | ( | Args &&... | args | ) |
Definition at line 1579 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::pushBack | ( | const Val & | val | ) |
Inserts a new element (a copy) at the end of the chained list.
The value passed in argument is not actually inserted into the list: this is a copy of this value that is inserted. The method runs in constant time.
val | The value pushed back. |
Definition at line 1592 of file list_tpl.h.
Referenced by gum::learning::Miic::__existsDirectedPath(), gum::BayesNetFactory< GUM_SCALAR >::__fillProbaWithValuesTable(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::ArcGraphPart::directedPath(), gum::ArcGraphPart::directedUnorientedPath(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::DiGraph::hasDirectedPath(), gum::Set< gum::Potential< GUM_SCALAR > * >::listMap(), gum::List< const gum::Potential< GUM_SCALAR > * >::map(), gum::MixedGraph::mixedOrientedPath(), gum::MixedGraph::mixedUnorientedPath(), and gum::EdgeGraphPart::undirectedPath().
INLINE Val & gum::List< Val, Alloc >::pushBack | ( | Val && | val | ) |
Inserts a new element (a move) at the end of the chained list.
The value passed in argument is not actually inserted into the list: this is a copy of this value that is inserted. The method runs in constant time.
val | The value pushed back. |
Definition at line 1598 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::pushFront | ( | const Val & | val | ) |
Inserts a new element (a copy) at the beginning of the chained list.
The value passed in argument is not actually inserted into the list: this is a copy of this value that is inserted. The method runs in constant time.
val | The valus pushed at the front. |
Definition at line 1566 of file list_tpl.h.
INLINE Val & gum::List< Val, Alloc >::pushFront | ( | Val && | val | ) |
Inserts a new element (a move) at the beginning of the chained list.
val | The valus pushed at the front. |
Definition at line 1572 of file list_tpl.h.
INLINE ListIterator< Val > gum::List< Val, Alloc >::rbegin | ( | ) |
Returns an unsafe iterator pointing to the last element of the List.
Unsafe iterators are a little bit faster than safe iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Definition at line 1456 of file list_tpl.h.
INLINE ListConstIterator< Val > gum::List< Val, Alloc >::rbegin | ( | ) | const |
Returns an unsafe const iterator pointing to the last element of the List.
Unsafe iterators are a little bit faster than safe iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Definition at line 1465 of file list_tpl.h.
INLINE ListIteratorSafe< Val > gum::List< Val, Alloc >::rbeginSafe | ( | ) |
Returns a safe iterator pointing to the last element of the List.
Safe iterators are iterators whose state is updated by the list when the element they point to is erased. As such, in this case, they can throw an exception when we try to derefence them and they are able to perform a valid ++ or – step.
Definition at line 1438 of file list_tpl.h.
|
noexcept |
Returns an unsafe iterator pointing just before the beginning of the List.
Unsafe iterators are a little bit faster than safe iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Returns an unsafe iterator pointing just before the beginning of the List.
Definition at line 1386 of file list_tpl.h.
|
noexcept |
Returns an unsafe const iterator pointing just before the beginning of the List.
Unsafe const iterators are a little bit faster than safe const iterators and they consume less memory. However, if the element they point to is erased, their dereference or their increment/decrement will produce a mess, probably a segfault. You should use them only when performance is an issue and if you are sure that they will never point to an element erased.
Definition at line 1392 of file list_tpl.h.
|
noexcept |
Returns a safe iterator pointing just before the beginning of the List.
Safe iterators are iterators whose state is updated by the list when the element they point to is erased. As such, in this case, they can throw an exception when we try to derefence them and they are able to perform a valid ++ or – step.
Definition at line 1373 of file list_tpl.h.
|
noexcept |
Returns the number of elements in the list.
This method runs in constant time.
Definition at line 1851 of file list_tpl.h.
Referenced by gum::BayesNetFactory< GUM_SCALAR >::__fillProbaWithValuesTable(), gum::BayesNetFactory< GUM_SCALAR >::__increment(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__insertEvidence(), and gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances().
INLINE void gum::List< Val, Alloc >::swap | ( | List< Val, Alloc > & | other_list | ) |
Swap the current list with another one.
other_list | The list to swap elements with. |
Definition at line 2115 of file list_tpl.h.
std::string gum::List< Val, Alloc >::toString | ( | ) | const |
Converts a list into a string.
Definition at line 1976 of file list_tpl.h.
|
friend |
ListIterator should be a friend to optimize access to elements.
|
friend |
ListIterator should be a friend to optimize access to elements.
|
friend |
ListIterator should be a friend to optimize access to elements.
|
friend |
ListIterator should be a friend to optimize access to elements.
|
mutableprivate |
The allocator for the buckets.
Definition at line 1314 of file list.h.
Referenced by gum::List< const gum::Potential< GUM_SCALAR > * >::swap().
|
private |
A pointer on the first element of the chained list.
Definition at line 1302 of file list.h.
Referenced by gum::List< const gum::Potential< GUM_SCALAR > * >::__copy_elements(), gum::ListConstIterator< Val >::ListConstIterator(), gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), gum::List< const gum::Potential< GUM_SCALAR > * >::operator==(), and gum::List< const gum::Potential< GUM_SCALAR > * >::swap().
|
private |
A pointer on the last element of the chained list.
Definition at line 1305 of file list.h.
Referenced by gum::ListConstIterator< Val >::ListConstIterator(), gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), and gum::List< const gum::Potential< GUM_SCALAR > * >::swap().
|
private |
The number of elements in the list.
Definition at line 1308 of file list.h.
Referenced by gum::List< const gum::Potential< GUM_SCALAR > * >::__copy_elements(), gum::ListConstIterator< Val >::ListConstIterator(), gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), gum::List< const gum::Potential< GUM_SCALAR > * >::operator==(), and gum::List< const gum::Potential< GUM_SCALAR > * >::swap().
|
mutableprivate |
The list of "safe" iterators attached to the list.
Definition at line 1311 of file list.h.
Referenced by gum::ListConstIteratorSafe< Val >::__removeFromSafeList(), gum::ListConstIteratorSafe< Val >::ListConstIteratorSafe(), gum::ListConstIteratorSafe< Val >::operator=(), and gum::List< const gum::Potential< GUM_SCALAR > * >::swap().