aGrUM  0.14.2
list.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 #ifndef GUM_LIST_H
28 #define GUM_LIST_H
29 
30 #include <cstddef>
31 #include <initializer_list>
32 #include <iostream>
33 #include <sstream>
34 #include <vector>
35 
36 #include <agrum/agrum.h>
37 #include <agrum/core/refPtr.h>
38 
39 #define GUM_DEFAULT_ITERATOR_NUMBER 4
40 
41 namespace gum {
42 
43  // ==============================================================================
44  // templates provided by this header
45  // ==============================================================================
46 
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 
49  template < typename Val >
50  class ListBucket;
51  template < typename Val >
52  class ListIterator;
53  template < typename Val >
54  class ListConstIterator;
55  template < typename Val >
56  class ListIteratorSafe;
57  template < typename Val >
58  class ListConstIteratorSafe;
59  template < typename Val, typename Alloc >
60  class List;
61 
62 #endif // DOXYGEN_SHOULD_SKIP_THIS
63 
64 #ifndef SWIG // SWIG cannot read these lines
65  template < typename Val, typename Alloc >
67  std::ostream& operator<<(std::ostream& stream, const List< Val, Alloc >& list);
68 #endif // SWIG
69 
70 #ifndef DOXYGEN_SHOULD_SKIP_THIS
71  // __list_end is a 'pseudo static' iterator that represents both end and rend
72  // iterators for all Lists (whatever their type). This global variable
73  // avoids creating the same iterators whithin every List instance (this would
74  // be quite inefficient as end and rend are precisely identical for all
75  // lists).
76  // The type of __list_end is a pointer to void because C++ allows pointers to
77  // void to be cast into pointers to other types (and conversely). This avoids
78  // the weird strict-aliasing rule warning
79  extern const void* const __list_end_safe;
80  extern const void* const __list_end;
81 #endif // DOXYGEN_SHOULD_SKIP_THIS
82 
83 
84  // ===========================================================================
85  // === BUCKETS: SINGLE ELEMENTS OF A CHAINED LIST ===
86  // ===========================================================================
87 
101  template < typename Val >
102  class ListBucket {
103  private:
109  enum class Emplace { EMPLACE };
110 
111  public:
112  // ============================================================================
114  // ============================================================================
116 
118  ListBucket() = delete;
119 
124  explicit ListBucket(const Val& v);
125 
130  explicit ListBucket(Val&& v) noexcept;
131 
137  template < typename... Args >
138  explicit ListBucket(Emplace, Args&&... args);
139 
144  ListBucket(const ListBucket< Val >& src);
145 
150  ListBucket(ListBucket< Val >&& src) = delete;
151 
161  ~ListBucket();
162 
164  // ============================================================================
166  // ============================================================================
168 
175 
182 
188  bool operator==(const ListBucket< Val >& src) const;
189 
195  bool operator!=(const ListBucket< Val >& src) const;
196 
198  // ============================================================================
200  // ============================================================================
202 
207  Val& operator*() noexcept;
208 
213  const Val& operator*() const noexcept;
214 
219  const ListBucket< Val >* next() const noexcept;
220 
225  const ListBucket< Val >* previous() const noexcept;
226 
228 
229  private:
232  template < typename T, typename A >
233  friend class List;
234  friend class ListIterator< Val >;
235  friend class ListConstIterator< Val >;
236  friend class ListIteratorSafe< Val >;
237  friend class ListConstIteratorSafe< Val >;
238 
244 
246  Val __val;
247  };
248 
249  // ===========================================================================
250  // === GENERIC DOUBLY CHAINED LISTS ===
251  // ===========================================================================
252 
368  template < typename Val, typename Alloc = std::allocator< Val > >
369  class List {
370  public:
373  using value_type = Val;
374  using reference = Val&;
375  using const_reference = const Val&;
376  using pointer = Val*;
377  using const_pointer = const Val*;
378  using size_type = Size;
379  using difference_type = std::ptrdiff_t;
380  using allocator_type = Alloc;
386 
388  using BucketAllocator =
389  typename Alloc::template rebind< ListBucket< Val > >::other;
390 
393  enum class location { BEFORE, AFTER };
394 
395  // ============================================================================
397  // ============================================================================
399 
403  List();
404 
415  List(const List< Val, Alloc >& src);
416 
428  template < typename OtherAlloc >
429  List(const List< Val, OtherAlloc >& src);
430 
435  List(List< Val, Alloc >&& src);
436 
441  List(std::initializer_list< Val > list);
442 
446  ~List();
447 
449  // ============================================================================
451  // ============================================================================
453 
464  const const_iterator_safe& cendSafe() const noexcept;
465 
476  const iterator_safe& endSafe() noexcept;
477 
490  const const_iterator_safe& crendSafe() const noexcept;
491 
504  const iterator_safe& rendSafe() noexcept;
505 
518  const_iterator_safe cbeginSafe() const;
519 
530  iterator_safe beginSafe();
531 
544  const_iterator_safe crbeginSafe() const;
545 
557  iterator_safe rbeginSafe();
558 
571  const const_iterator& cend() const noexcept;
572 
585  const iterator& end() noexcept;
586 
600  const const_iterator& end() const noexcept;
601 
616  const const_iterator& crend() const noexcept;
617 
632  const iterator& rend() noexcept;
633 
648  const const_iterator& rend() const noexcept;
649 
664  const_iterator cbegin() const;
665 
679  iterator begin();
680 
695  const_iterator begin() const;
696 
711  const_iterator crbegin() const;
712 
727  iterator rbegin();
728 
743  const_iterator rbegin() const;
744 
746  // ============================================================================
748  // ============================================================================
750 
764  Val& pushFront(const Val& val);
765 
775  Val& pushFront(Val&& val);
776 
786  template < typename... Args >
787  Val& push_front(Args&&... args);
788 
798  template < typename... Args >
799  Val& emplaceFront(Args&&... args);
800 
813  Val& pushBack(const Val& val);
814 
827  Val& pushBack(Val&& val);
828 
837  template < typename... Args >
838  Val& push_back(Args&&... args);
839 
850  template < typename... Args >
851  Val& emplaceBack(Args&&... args);
852 
862  Val& insert(const Val& val);
863 
873  Val& insert(Val&& val);
874 
888  Val& insert(Size pos, const Val& val);
889 
901  Val& insert(Size pos, Val&& val);
902 
913  Val& insert(const const_iterator_safe& iter,
914  const Val& val,
915  location place = location::BEFORE);
916 
927  Val& insert(const const_iterator_safe& iter,
928  Val&& val,
929  location place = location::BEFORE);
930 
941  Val& insert(const const_iterator& iter,
942  const Val& val,
943  location place = location::BEFORE);
944 
955  Val& insert(const const_iterator& iter,
956  Val&& val,
957  location place = location::BEFORE);
958 
972  template < typename... Args >
973  Val& emplace(const const_iterator& iter, Args&&... args);
974 
988  template < typename... Args >
989  Val& emplace(const const_iterator_safe& iter, Args&&... args);
990 
995  Val& front() const;
996 
1001  Val& back() const;
1002 
1007  Size size() const noexcept;
1008 
1019  bool exists(const Val& val) const;
1020 
1030  void erase(Size i);
1031 
1041  void erase(const iterator_safe& iter);
1042 
1053  void erase(const const_iterator_safe& iter);
1054 
1065  void eraseByVal(const Val& val);
1066 
1077  void eraseAllVal(const Val& val);
1078 
1084  void popBack();
1085 
1091  void popFront();
1092 
1100  void clear();
1101 
1106  bool empty() const noexcept;
1107 
1112  void swap(List& other_list);
1113 
1118  std::string toString() const;
1119 
1127  template < typename Mount, typename OtherAlloc = std::allocator< Mount > >
1128  List< Mount, OtherAlloc > map(Mount (*f)(Val)) const;
1129 
1137  template < typename Mount, typename OtherAlloc = std::allocator< Mount > >
1138  List< Mount, OtherAlloc > map(Mount (*f)(Val&)) const;
1139 
1147  template < typename Mount, typename OtherAlloc = std::allocator< Mount > >
1148  List< Mount, OtherAlloc > map(Mount (*f)(const Val&)) const;
1149 
1158  template < typename Mount, typename OtherAlloc = std::allocator< Mount > >
1159  List< Mount, OtherAlloc > map(const Mount& mount) const;
1160 
1162  // ============================================================================
1164  // ============================================================================
1166 
1186 
1204  template < typename OtherAlloc >
1206 
1214 
1227  Val& operator+=(const Val& val);
1228 
1241  Val& operator+=(Val&& val);
1242 
1252  template < typename OtherAlloc >
1253  bool operator==(const List< Val, OtherAlloc >& src) const;
1254 
1264  template < typename OtherAlloc >
1265  bool operator!=(const List< Val, OtherAlloc >& src) const;
1266 
1279  Val& operator[](const Size i);
1280 
1293  const Val& operator[](const Size i) const;
1294 
1296 
1297  private:
1299  ListBucket< Val >* __deb_list{nullptr};
1300 
1302  ListBucket< Val >* __end_list{nullptr};
1303 
1305  Size __nb_elements{Size(0)};
1306 
1308  mutable std::vector< const_iterator_safe* > __safe_iterators;
1309 
1312 
1322  template < typename OtherAlloc >
1323  void __copy_elements(const List< Val, OtherAlloc >& src);
1324 
1334  ListBucket< Val >* __getIthBucket(Size i) const noexcept;
1335 
1349  ListBucket< Val >* __getBucket(const Val& val) const noexcept;
1350 
1362  void __erase(ListBucket< Val >* bucket);
1363 
1369  ListBucket< Val >* __createBucket(const Val& val) const;
1370 
1376  ListBucket< Val >* __createBucket(Val&& val) const;
1377 
1384  template < typename... Args >
1385  ListBucket< Val >* __createEmplaceBucket(Args&&... args) const;
1386 
1392  Val& __pushFront(ListBucket< Val >* new_elt);
1393 
1399  Val& __pushBack(ListBucket< Val >* new_elt);
1400 
1407  Val& __insertBefore(ListBucket< Val >* new_elt,
1408  ListBucket< Val >* current_elt);
1409 
1416  Val& __insertAfter(ListBucket< Val >* new_elt, ListBucket< Val >* current_elt);
1417 
1426  Val& __insert(const const_iterator_safe& iter,
1427  ListBucket< Val >* new_elt,
1428  location place);
1429 
1438  Val& __insert(const const_iterator& iter,
1439  ListBucket< Val >* new_elt,
1440  location place);
1441 
1444  friend class ListIterator< Val >;
1445  friend class ListConstIterator< Val >;
1446  friend class ListIteratorSafe< Val >;
1447  friend class ListConstIteratorSafe< Val >;
1449  };
1450 
1451  // ===========================================================================
1452  // === UNSAFE LIST CONST ITERATORS ===
1453  // ===========================================================================
1504  template < typename Val >
1506  public:
1509  using iterator_category = std::bidirectional_iterator_tag;
1510  using value_type = Val;
1511  using reference = Val&;
1512  using const_reference = const Val&;
1513  using pointer = Val*;
1514  using const_pointer = const Val*;
1515  using difference_type = std::ptrdiff_t;
1517 
1518  // ============================================================================
1520  // ============================================================================
1522 
1528  ListConstIterator() noexcept;
1529 
1534  template < typename Alloc >
1535  ListConstIterator(const List< Val, Alloc >& theList) noexcept;
1536 
1541  ListConstIterator(const ListConstIterator< Val >& src) noexcept;
1542 
1547  ListConstIterator(ListConstIterator< Val >&& src) noexcept;
1548 
1557  ListConstIterator(const List< Val >& theList, Size ind_elt);
1558 
1562  ~ListConstIterator() noexcept;
1563 
1565  // ============================================================================
1567  // ============================================================================
1569 
1577  void clear() noexcept;
1578 
1582  void setToEnd() noexcept;
1583 
1590  bool isEnd() const noexcept;
1591 
1593  // ============================================================================
1595  // ============================================================================
1597 
1606  ListConstIterator< Val >&
1607  operator=(const ListConstIterator< Val >& src) noexcept;
1608 
1615  ListConstIterator< Val >& operator=(ListConstIterator< Val >&& src) noexcept;
1616 
1630  ListConstIterator< Val >& operator++() noexcept;
1631 
1637  ListConstIterator< Val >& operator+=(difference_type i) noexcept;
1638 
1652  ListConstIterator< Val >& operator--() noexcept;
1653 
1660  ListConstIterator< Val >& operator-=(difference_type i) noexcept;
1661 
1668  ListConstIterator< Val > operator+(difference_type i) noexcept;
1669 
1676  ListConstIterator< Val > operator-(difference_type i) noexcept;
1677 
1687  bool operator!=(const ListConstIterator< Val >& src) const noexcept;
1688 
1698  bool operator==(const ListConstIterator< Val >& src) const noexcept;
1699 
1705  const Val& operator*() const;
1706 
1712  const Val* operator->() const;
1713 
1715 
1716  private:
1721  template < typename T, typename A >
1722  friend class List;
1723 
1725  ListBucket< Val >* __bucket{nullptr};
1726 
1728  ListBucket< Val >* __getBucket() const noexcept;
1729  };
1730 
1732  template < typename Val >
1734  operator-(const ListConstIterator< Val >& iter1,
1735  const ListConstIterator< Val >& iter2);
1736 
1737  // ===========================================================================
1738  // === UNSAFE LIST ITERATORS ===
1739  // ===========================================================================
1740 
1790  template < typename Val >
1791  class ListIterator : public ListConstIterator< Val > {
1792  public:
1795  using iterator_category = std::bidirectional_iterator_tag;
1796  using value_type = Val;
1797  using reference = Val&;
1798  using const_reference = const Val&;
1799  using pointer = Val*;
1800  using const_pointer = const Val*;
1801  using difference_type = std::ptrdiff_t;
1803 
1804  // ============================================================================
1806  // ============================================================================
1808 
1814  ListIterator() noexcept;
1815 
1821  template < typename Alloc >
1822  ListIterator(const List< Val, Alloc >& theList) noexcept;
1823 
1828  ListIterator(const ListIterator< Val >& src) noexcept;
1829 
1834  ListIterator(ListIterator< Val >&& src) noexcept;
1835 
1844  ListIterator(const List< Val >& theList, Size ind_elt);
1845 
1849  ~ListIterator() noexcept;
1850 
1852  // ============================================================================
1854  // ============================================================================
1856 
1857  using ListConstIterator< Val >::clear;
1858  using ListConstIterator< Val >::setToEnd;
1859  using ListConstIterator< Val >::isEnd;
1860 
1862 
1863  // ============================================================================
1865  // ============================================================================
1867 
1876  ListIterator< Val >& operator=(const ListIterator< Val >& src) noexcept;
1877 
1879 
1887  ListIterator< Val >& operator=(ListIterator< Val >&& src) noexcept;
1888 
1903  ListIterator< Val >& operator++() noexcept;
1904 
1910  ListIterator< Val >& operator+=(difference_type i) noexcept;
1911 
1925  ListIterator< Val >& operator--() noexcept;
1926 
1933  ListIterator< Val >& operator-=(difference_type i) noexcept;
1934 
1941  ListIterator< Val > operator+(difference_type i) noexcept;
1942 
1949  ListIterator< Val > operator-(difference_type i) noexcept;
1950 
1953  using ListConstIterator< Val >::operator==;
1954  using ListConstIterator< Val >::operator!=;
1955  using ListConstIterator< Val >::operator*;
1956  using ListConstIterator< Val >::operator->;
1958 
1965  Val& operator*();
1966 
1973  Val* operator->();
1974 
1976  };
1977 
1978  // ===========================================================================
1979  // === LIST CONST ITERATORS ===
1980  // ===========================================================================
2026  template < typename Val >
2028  public:
2031  using iterator_category = std::bidirectional_iterator_tag;
2032  using value_type = Val;
2033  using reference = Val&;
2034  using const_reference = const Val&;
2035  using pointer = Val*;
2036  using const_pointer = const Val*;
2037  using difference_type = std::ptrdiff_t;
2039 
2040  // ============================================================================
2042  // ============================================================================
2044 
2050  ListConstIteratorSafe() noexcept;
2051 
2056  template < typename Alloc >
2057  ListConstIteratorSafe(const List< Val, Alloc >& theList);
2058 
2063  ListConstIteratorSafe(const ListConstIteratorSafe< Val >& src);
2064 
2073  template < typename Alloc >
2074  ListConstIteratorSafe(const List< Val, Alloc >& theList, Size ind_elt);
2075 
2080  ListConstIteratorSafe(ListConstIteratorSafe< Val >&& src);
2081 
2085  ~ListConstIteratorSafe();
2086 
2088  // ============================================================================
2090  // ============================================================================
2092 
2101  void clear();
2102 
2106  void setToEnd();
2107 
2114  bool isEnd() const;
2115 
2117  // ============================================================================
2119  // ============================================================================
2121 
2130  ListConstIteratorSafe< Val >&
2131  operator=(const ListConstIteratorSafe< Val >& src);
2132 
2139  ListConstIteratorSafe< Val >& operator=(ListConstIteratorSafe< Val >&& src);
2140 
2154  ListConstIteratorSafe< Val >& operator++() noexcept;
2155 
2161  ListConstIteratorSafe< Val >& operator+=(difference_type i) noexcept;
2162 
2176  ListConstIteratorSafe< Val >& operator--() noexcept;
2177 
2184  ListConstIteratorSafe< Val >& operator-=(difference_type i) noexcept;
2185 
2192  ListConstIteratorSafe< Val > operator+(difference_type i) noexcept;
2193 
2200  ListConstIteratorSafe< Val > operator-(difference_type i) noexcept;
2201 
2211  bool operator!=(const ListConstIteratorSafe< Val >& src) const;
2212 
2222  bool operator==(const ListConstIteratorSafe< Val >& src) const;
2223 
2229  const Val& operator*() const;
2230 
2236  const Val* operator->() const;
2237 
2239 
2240  private:
2244  template < typename T, typename A >
2245  friend class List;
2246  friend class ListConstIterator< Val >;
2248 
2250  const List< Val, std::allocator< Val > >* __list{nullptr};
2251 
2253  ListBucket< Val >* __bucket{nullptr};
2254 
2257  ListBucket< Val >* __next_current_bucket{nullptr};
2258 
2261  ListBucket< Val >* __prev_current_bucket{nullptr};
2262 
2264  bool __null_pointing{false};
2265 
2267  ListBucket< Val >* __getBucket() const noexcept;
2268 
2270  void __removeFromSafeList() const;
2271 
2273  ListConstIteratorSafe< Val >& __opPlus(Size i) noexcept;
2274 
2276  ListConstIteratorSafe< Val >& __opMinus(Size i) noexcept;
2277  };
2278 
2280  template < typename Val >
2283  const ListConstIteratorSafe< Val >& iter2);
2284 
2285  // ===========================================================================
2286  // === LIST ITERATORS ===
2287  // ===========================================================================
2288 
2338  template < typename Val >
2339  class ListIteratorSafe : public ListConstIteratorSafe< Val > {
2340  public:
2343  using iterator_category = std::bidirectional_iterator_tag;
2344  using value_type = Val;
2345  using reference = Val&;
2346  using const_reference = const Val&;
2347  using pointer = Val*;
2348  using const_pointer = const Val*;
2349  using difference_type = std::ptrdiff_t;
2351 
2352  // ============================================================================
2354  // ============================================================================
2356 
2362  ListIteratorSafe() noexcept;
2363 
2368  template < typename Alloc >
2369  ListIteratorSafe(const List< Val, Alloc >& theList);
2370 
2375  ListIteratorSafe(const ListIteratorSafe< Val >& src);
2376 
2385  template < typename Alloc >
2386  ListIteratorSafe(const List< Val, Alloc >& theList, Size ind_elt);
2387 
2392  ListIteratorSafe(ListIteratorSafe< Val >&& src);
2393 
2397  ~ListIteratorSafe();
2398 
2400  // ============================================================================
2402  // ============================================================================
2404 
2405  using ListConstIteratorSafe< Val >::clear;
2406  using ListConstIteratorSafe< Val >::setToEnd;
2407  using ListConstIteratorSafe< Val >::isEnd;
2408 
2410  // ============================================================================
2412  // ============================================================================
2414 
2423  ListIteratorSafe< Val >& operator=(const ListIteratorSafe< Val >& src);
2424 
2431  ListIteratorSafe< Val >& operator=(ListIteratorSafe< Val >&& src);
2432 
2446  ListIteratorSafe< Val >& operator++() noexcept;
2447 
2453  ListIteratorSafe< Val >& operator+=(difference_type i) noexcept;
2454 
2468  ListIteratorSafe< Val >& operator--() noexcept;
2469 
2476  ListIteratorSafe< Val >& operator-=(difference_type i) noexcept;
2477 
2484  ListIteratorSafe< Val > operator+(difference_type i) noexcept;
2485 
2492  ListIteratorSafe< Val > operator-(difference_type i) noexcept;
2493 
2499  Val& operator*();
2500 
2506  Val* operator->();
2507 
2510  using ListConstIteratorSafe< Val >::operator!=;
2511  using ListConstIteratorSafe< Val >::operator==;
2512  using ListConstIteratorSafe< Val >::operator*;
2513  using ListConstIteratorSafe< Val >::operator->;
2515  };
2516 
2517 #ifndef DOXYGEN_SHOULD_SKIP_THIS
2518  // constructor and destructor for the iterator that represents end and rend
2519  template <>
2521  template <>
2523  template <>
2524  ListConstIterator< Debug >::ListConstIterator() noexcept;
2525  template <>
2526  ListConstIterator< Debug >::~ListConstIterator() noexcept;
2527 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
2528 
2529 } /* namespace gum */
2530 
2531 
2532 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
2533 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
2534 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
2535 extern template class gum::List< bool >;
2536 # endif
2537 # endif
2538 #endif
2539 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
2540 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
2541 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
2542 extern template class gum::List< int >;
2543 # endif
2544 # endif
2545 #endif
2546 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
2547 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
2548 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
2549 extern template class gum::List< unsigned int >;
2550 # endif
2551 # endif
2552 #endif
2553 
2554 
2555 // always include the implementation of the templates
2556 #include <agrum/core/list_tpl.h>
2557 
2558 #endif /* GUM_LIST_H */
ListBucket< Val > * __next
Chaining toward the adjacent elements.
Definition: list.h:242
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:57
ListConstIteratorSafe() noexcept
Default constructor.
Definition: list_tpl.h:489
Val & reference
Types for STL compliance.
Definition: list.h:1511
Val value_type
Types for STL compliance.
Definition: list.h:1510
Safe iterators for Lists.
Definition: list.h:2339
ListBucket< Val > * __prev
Chaining toward the adjacent elements.
Definition: list.h:241
Unsafe but fast iterators for Lists.
Definition: list.h:1791
location
Locations around iterators where insertions of new elements can take / place.
Definition: list.h:393
const Val & const_reference
Types for STL compliance.
Definition: list.h:1512
STL namespace.
std::ptrdiff_t difference_type
Types for STL compliance.
Definition: list.h:1515
Class providing aGrUM&#39;s "smart" pointers.
Generic doubly linked lists.
Definition: list.h:369
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
std::allocator< const gum::Potential< GUM_SCALAR > * > allocator_type
Definition: list.h:380
bool operator!=(const ListBucket< Val > &src) const
Inequality check.
Definition: list_tpl.h:98
const ListBucket< Val > * previous() const noexcept
Returns the bucket toward the preceding element.
Definition: list_tpl.h:122
friend class List
All the list containers and iterators should be able to access the buckets.
Definition: list.h:233
Val * pointer
Types for STL compliance.
Definition: list.h:2035
Emplace
C dummy type for the emplace constructor.
Definition: list.h:109
std::vector< const_iterator_safe *> __safe_iterators
The list of "safe" iterators attached to the list.
Definition: list.h:1308
ListBucket()=delete
Removes empty constructor.
const const gum::Potential< GUM_SCALAR > * & const_reference
Definition: list.h:375
Val * pointer
Types for STL compliance.
Definition: list.h:1513
std::bidirectional_iterator_tag iterator_category
Types for STL compliance.
Definition: list.h:2031
std::ptrdiff_t difference_type
Types for STL compliance.
Definition: list.h:2037
Val & reference
Types for STL compliance.
Definition: list.h:2033
bool operator==(const ListBucket< Val > &src) const
Equality check.
Definition: list_tpl.h:92
ListConstIterator< Val >::difference_type operator-(const ListConstIterator< Val > &iter1, const ListConstIterator< Val > &iter2)
For STL compliance, a distance operator.
Definition: list_tpl.h:346
const ListBucket< Val > * next() const noexcept
Returns the bucket toward the next element.
Definition: list_tpl.h:116
Unsafe but fast const iterators for Lists.
Definition: list.h:1505
const const gum::Potential< GUM_SCALAR > * * const_pointer
Definition: list.h:377
Val & operator*() noexcept
Dereferencing operator.
Definition: list_tpl.h:110
Val __val
Val is the value contained in the box.
Definition: list.h:246
const Val * const_pointer
Types for STL compliance.
Definition: list.h:2036
ListBucket< Val > & operator=(const ListBucket< Val > &src)
Copy operator.
Definition: list_tpl.h:73
Safe const iterators for Lists.
Definition: list.h:2027
Bucket for a chained list.
Definition: list.h:102
const Val & const_reference
Types for STL compliance.
Definition: list.h:2034
template implementation of chained lists
~ListBucket()
Class destructor.
Definition: list_tpl.h:85
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
void swap(RefPtr< Val > &ptr1, RefPtr< Val > &ptr2)
Swap the contents of two RefPtr.
Definition: refPtr_tpl.h:257
BucketAllocator __alloc_bucket
The allocator for the buckets.
Definition: list.h:1311
const Val * const_pointer
Types for STL compliance.
Definition: list.h:1514
typename std::allocator< const gum::Potential< GUM_SCALAR > * > ::template rebind< ListBucket< const gum::Potential< GUM_SCALAR > * > >::other BucketAllocator
Type of the allocator for ListBuckets.
Definition: list.h:389
Val value_type
Types for STL compliance.
Definition: list.h:2032
std::bidirectional_iterator_tag iterator_category
Types for STL compliance.
Definition: list.h:1509