aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
bijection.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
52#ifndef GUM_BIJECTION_H
53#define GUM_BIJECTION_H
54
55#include <iostream>
56#include <sstream>
57#include <string>
58
60
61#include <initializer_list>
62#include <type_traits>
63
64namespace gum {
65
66#ifndef DOXYGEN_SHOULD_SKIP_THIS
67
68 template < typename T1, typename T2 >
70 template < typename T1, typename T2 >
72 template < typename T1, typename T2, bool >
74 template < typename T1, typename T2 >
75 class Bijection;
76
77#endif /* DOXYGEN_SHOULD_SKIP_THIS */
78
79
80 // ===========================================================================
81 // === NON SCALAR BIJECTION IMPLEMENTATION ===
82 // ===========================================================================
83
103 template < typename T1, typename T2, bool Gen >
105 public:
108 using type1_type = T1;
109 using type1_reference = T1&;
110 using type1_const_reference = const T1&;
111 using type1_pointer = T1*;
112 using type1_const_pointer = const T1*;
113 using type2_type = T2;
114 using type2_reference = T2&;
115 using type2_const_reference = const T2&;
116 using type2_pointer = T2*;
117 using type2_const_pointer = const T2*;
118 using size_type = std::size_t;
119 using difference_type = std::ptrdiff_t;
125
126 private:
134 BijectionImplementation(Size size, bool resize_policy);
135
140 BijectionImplementation(std::initializer_list< std::pair< T1, T2 > > list);
141
147
153
154 public:
155 // ============================================================================
157 // ============================================================================
159
164
166
167 private:
175
183
184 public:
185 // ============================================================================
187 // ============================================================================
189
212
235
256 const iterator& end() const noexcept;
257
278 const const_iterator& cend() const noexcept;
279
302
326
348 const iterator_safe& endSafe() const noexcept;
349
372 const const_iterator_safe& cendSafe() const noexcept;
373
375
376 // ============================================================================
378 // ============================================================================
380
387 const T1& first(const T2& second) const;
388
398 const T1& firstWithDefault(const T2& second, const T1& default_val) const;
399
406 const T2& second(const T1& first) const;
407
409 template < typename K >
410 requires(std::same_as< T1, std::string > && std::convertible_to< K, std::string_view >
411 && !std::same_as< std::decay_t< K >, std::string >)
412 const T2& second(const K& first) const;
413
423 const T2& secondWithDefault(const T1& second, const T2& default_val) const;
424
432 bool existsFirst(const T1& first) const;
433
435 template < typename K >
436 requires(std::same_as< T1, std::string > && std::convertible_to< K, std::string_view >
437 && !std::same_as< std::decay_t< K >, std::string >)
438 bool existsFirst(const K& first) const;
439
447 bool existsSecond(const T2& second) const;
448
455 optional_ref< const T1 > tryFirst(const T2& second) const;
456
463 optional_ref< const T2 > trySecond(const T1& first) const;
464
466 template < typename K >
467 requires(std::same_as< T1, std::string > && std::convertible_to< K, std::string_view >
468 && !std::same_as< std::decay_t< K >, std::string >)
469 optional_ref< const T2 > trySecond(const K& first) const;
470
480 void insert(const T1& first, const T2& second);
481
491 void insert(T1&& first, T2&& second);
492
503 template < typename... Args >
504 void emplace(Args&&... args);
505
509 void clear();
510
517 bool empty() const noexcept;
518
525 Size size() const noexcept;
526
535 void eraseFirst(const T1& first);
536
545 void eraseSecond(const T2& second);
546
551 std::string toString() const;
552
554 // ============================================================================
556 // ============================================================================
558
563 Size capacity() const noexcept;
564
572 void resize(Size new_size);
573
581 void setResizePolicy(const bool new_policy) noexcept;
582
590 bool resizePolicy() const noexcept;
591
593
594 private:
597 using HashTable12 = HashTable< T1, T2* >;
598 using HashTable21 = HashTable< T2, T1* >;
600
603 friend class BijectionIteratorSafe< T1, T2 >;
604 friend class BijectionIterator< T1, T2 >;
605 friend class Bijection< T1, T2 >;
606 template < typename TT1, typename TT2, bool >
609
610 // Below, we create the two gum::HashTable used by the gum::Bijection. Note
611 // that the values of these gum::HashTable are pointers. This enables to
612 // create only once objects (T1,T2). When using gum::Bijection with large
613 // size objects, this feature is of particular interest.
614
617
620
629 void _copy_(const HashTable< T1, T2* >& source);
630
637 typename HashTable12::value_type* _insert_(const T1& first, const T2& second);
638
645 typename HashTable12::value_type* _insert_(T1&& first, T2&& second);
646 };
647
648#ifndef DOXYGEN_SHOULD_SKIP_THIS
649
650 // ===========================================================================
651 // === SCALAR BIJECTION IMPLEMENTATION ===
652 // ===========================================================================
653
676 template < typename T1, typename T2 >
677 class BijectionImplementation< T1, T2, true > {
678 public:
681 using type1_type = T1;
682 using type1_reference = T1&;
683 using type1_const_reference = const T1&;
684 using type1_pointer = T1*;
685 using type1_const_pointer = const T1*;
686 using type2_type = T2;
687 using type2_reference = T2&;
688 using type2_const_reference = const T2&;
689 using type2_pointer = T2*;
690 using type2_const_pointer = const T2*;
691 using size_type = std::size_t;
692 using difference_type = std::ptrdiff_t;
698
699 private:
707 BijectionImplementation(Size size, bool resize_policy);
708
713 BijectionImplementation(std::initializer_list< std::pair< T1, T2 > > list);
714
720
726
727 public:
728 // ============================================================================
730 // ============================================================================
732
737
739
740 private:
748
756
757 public:
758 // ============================================================================
760 // ============================================================================
762
784 iterator begin() const;
785
807 const_iterator cbegin() const;
808
829 const iterator& end() const noexcept;
830
851 const const_iterator& cend() const noexcept;
852
874 iterator_safe beginSafe() const;
875
899
921 const iterator_safe& endSafe() const noexcept;
922
945 const const_iterator_safe& cendSafe() const noexcept;
946
948
949 // ============================================================================
951 // ============================================================================
953
960 const T1& first(T2 second) const;
961
971 const T1& firstWithDefault(T2 second, T1 default_val) const;
972
979 const T2& second(T1 first) const;
980
990 const T2& secondWithDefault(T1 first, T2 default_val) const;
991
999 bool existsFirst(T1 first) const;
1000
1008 bool existsSecond(T2 second) const;
1009
1017
1025
1035 void insert(T1 first, T2 second);
1036
1047 template < typename... Args >
1048 void emplace(Args&&... args);
1049
1053 void clear();
1054
1061 bool empty() const noexcept;
1062
1069 Size size() const noexcept;
1070
1079 void eraseFirst(T1 first);
1080
1089 void eraseSecond(T2 second);
1090
1095 std::string toString() const;
1096
1098 // ============================================================================
1100 // ============================================================================
1102
1107 Size capacity() const noexcept;
1108
1116 void resize(Size new_size);
1117
1125 void setResizePolicy(const bool new_policy) noexcept;
1126
1134 bool resizePolicy() const noexcept;
1135
1137
1138 private:
1144
1147 friend class BijectionIteratorSafe< T1, T2 >;
1148 friend class BijectionIterator< T1, T2 >;
1149 friend class Bijection< T1, T2 >;
1150 template < typename TT1, typename TT2, bool >
1151 friend class BijectionImplementation;
1153
1154 // Below, we create the two gum::HashTable used by the gum::Bijection. Note
1155 // that the values of these gum::HashTable are pointers. This enables to
1156 // create only once objects (T1,T2). When using gum::Bijection with large
1157 // size objects, this feature is of particular interest.
1158
1161
1164
1173 void _copy_(const HashTable< T1, T2 >& f2s);
1174
1181 void _insert_(const T1 first, const T2 second);
1182 };
1183
1184#endif /* DOXYGEN_SHOULD_SKIP_THIS */
1185
1195 template < bool gen >
1202 template < typename T >
1203 static const T& op_second(const T* x);
1204 };
1205
1215 template <>
1216 struct BijectionIteratorGet< true > {
1222 template < typename T >
1223 static const T& op_second(const T& x);
1224 };
1225
1226 // ===========================================================================
1227 // === BIJECTION SAFE ITERATORS ===
1228 // ===========================================================================
1229
1239 template < typename T1, typename T2 >
1241 template < typename TT1, typename TT2, bool >
1243
1244 public:
1247 using iterator_category = std::forward_iterator_tag;
1248 using type1_type = T1;
1249 using type1_reference = T1&;
1250 using type1_const_reference = const T1&;
1251 using type1_pointer = T1*;
1252 using type1_const_pointer = const T1*;
1253 using type2_type = T2;
1254 using type2_reference = T2&;
1255 using type2_const_reference = const T2&;
1256 using type2_pointer = T2*;
1257 using type2_const_pointer = const T2*;
1258 using difference_type = std::ptrdiff_t;
1260
1261 private:
1267 = BijectionIteratorGet< std::is_scalar< T1 >::value && std::is_scalar< T2 >::value >;
1268
1275 template < bool Gen >
1277
1278 public:
1279 // ============================================================================
1281 // ============================================================================
1283
1287 explicit BijectionIteratorSafe() noexcept;
1288
1289#ifndef DOXYGEN_SHOULD_SKIP_THIS
1290 // constructor for the static endSafe iterator
1291 // only bijection.cpp should use this constructor
1292 explicit consteval BijectionIteratorSafe(StaticInitializer init) noexcept : _iter_(init) {}
1293#endif // DOXYGEN_SHOULD_SKIP_THIS
1294
1302
1308
1314
1318 ~BijectionIteratorSafe() noexcept;
1319
1321 // ============================================================================
1323 // ============================================================================
1325
1331 BijectionIteratorSafe< T1, T2 >& operator=(const BijectionIteratorSafe< T1, T2 >& toCopy);
1332
1338 BijectionIteratorSafe< T1, T2 >& operator=(BijectionIteratorSafe< T1, T2 >&& toMove) noexcept;
1339
1346 BijectionIteratorSafe< T1, T2 >& operator++() noexcept;
1347
1359 BijectionIteratorSafe< T1, T2 >& operator+=(Size nb) noexcept;
1360
1372 BijectionIteratorSafe< T1, T2 > operator+(Size nb) noexcept;
1373
1379 bool operator!=(const BijectionIteratorSafe< T1, T2 >& toCompare) const noexcept;
1380
1386 bool operator==(const BijectionIteratorSafe< T1, T2 >& toCompare) const noexcept;
1387
1389 // ============================================================================
1391 // ============================================================================
1393
1400 const T1& first() const;
1401
1408 const T2& second() const;
1409
1411
1412 private:
1414 using HashTable12 =
1415 typename std::conditional< std::is_scalar< T1 >::value && std::is_scalar< T2 >::value,
1416 HashTable< T1, T2 >,
1417 HashTable< T1, T2* > >::type;
1418
1421 using HashIter = typename HashTable12::const_iterator_safe;
1422
1425 };
1426
1427 // ===========================================================================
1428 // === BIJECTION UNSAFE ITERATORS ===
1429 // ===========================================================================
1439 template < typename T1, typename T2 >
1441 template < typename TT1, typename TT2, bool >
1443
1444 public:
1447 using iterator_category = std::forward_iterator_tag;
1448 using type1_type = T1;
1449 using type1_reference = T1&;
1450 using type1_const_reference = const T1&;
1451 using type1_pointer = T1*;
1452 using type1_const_pointer = const T1*;
1453 using type2_type = T2;
1454 using type2_reference = T2&;
1455 using type2_const_reference = const T2&;
1456 using type2_pointer = T2*;
1457 using type2_const_pointer = const T2*;
1458 using difference_type = std::ptrdiff_t;
1460
1461 private:
1467 = BijectionIteratorGet< std::is_scalar< T1 >::value && std::is_scalar< T2 >::value >;
1468
1473 template < bool Gen >
1475
1476 public:
1477 // ============================================================================
1479 // ============================================================================
1481
1485 explicit BijectionIterator() noexcept;
1486
1487#ifndef DOXYGEN_SHOULD_SKIP_THIS
1488 // constructor for the static end iterator
1489 // only bijection.cpp should use this constructor
1490 explicit consteval BijectionIterator(StaticInitializer init) noexcept : _iter_(init) {}
1491#endif // DOXYGEN_SHOULD_SKIP_THIS
1492
1497 BijectionIterator(const Bijection< T1, T2 >& bijection);
1498
1504
1510
1514 ~BijectionIterator() noexcept;
1515
1517 // ============================================================================
1519 // ============================================================================
1521
1527 BijectionIterator< T1, T2 >& operator=(const BijectionIterator< T1, T2 >& toCopy);
1528
1534 BijectionIterator< T1, T2 >& operator=(BijectionIterator< T1, T2 >&& toMove) noexcept;
1535
1543 BijectionIterator< T1, T2 >& operator++() noexcept;
1544
1556 BijectionIterator< T1, T2 >& operator+=(Size nb) noexcept;
1557
1566 BijectionIterator< T1, T2 > operator+(Size nb) noexcept;
1567
1573 bool operator!=(const BijectionIterator< T1, T2 >& toCompare) const noexcept;
1574
1580 bool operator==(const BijectionIterator< T1, T2 >& toCompare) const noexcept;
1581
1583 // ============================================================================
1585 // ============================================================================
1587
1594 const T1& first() const;
1595
1602 const T2& second() const;
1603
1605
1606 private:
1608 using HashTable12 =
1609 typename std::conditional< std::is_scalar< T1 >::value && std::is_scalar< T2 >::value,
1610 HashTable< T1, T2 >,
1611 HashTable< T1, T2* > >::type;
1612 using HashIter = typename HashTable12::const_iterator;
1613
1616 };
1617
1636 template < typename T1, typename T2 >
1638 public BijectionImplementation< T1,
1639 T2,
1640 std::is_scalar< T1 >::value && std::is_scalar< T2 >::value > {
1641 public:
1644 using type1_type = T1;
1645 using type1_reference = T1&;
1646 using type1_const_reference = const T1&;
1647 using type1_pointer = T1*;
1648 using type1_const_pointer = const T1*;
1649 using type2_type = T2;
1650 using type2_reference = T2&;
1651 using type2_const_reference = const T2&;
1652 using type2_pointer = T2*;
1653 using type2_const_pointer = const T2*;
1654 using size_type = std::size_t;
1655 using difference_type = std::ptrdiff_t;
1661
1665 T2,
1666 std::is_scalar< T1 >::value && std::is_scalar< T2 >::value >;
1667
1668 // ============================================================================
1670 // ============================================================================
1672
1681 bool resize_policy = HashTableConst::default_resize_policy);
1682
1687 Bijection(std::initializer_list< std::pair< T1, T2 > > list);
1688
1693 Bijection(const Bijection< T1, T2 >& toCopy);
1694
1699 Bijection(Bijection< T1, T2 >&& from) noexcept;
1700
1704 ~Bijection();
1705
1707 // ============================================================================
1709 // ============================================================================
1711
1718
1724
1726 };
1727
1728
1729#ifndef DOXYGEN_SHOULD_SKIP_THIS
1730 // _static_Bijection_end_ is a 'constant' iterator initialized at compile time
1731 // that represents the end iterators for all bijections (whatever their
1732 // type). This global variable avoids creating the same iterators within every
1733 // Bijection instance (this would be quite inefficient as end is precisely
1734 // identical for all bijections). The same hold for safe end iterators.
1735 // The type of _Bijection_end_ is a pointer to void because C++ allows
1736 // pointers to void to be cast into pointers to other types (and conversely).
1737 // This avoids the painful strict-aliasing rule warning
1738 extern const BijectionIterator< int, int > _static_Bijection_end_;
1739 extern const BijectionIteratorSafe< int, int > _static_Bijection_end_safe_;
1740
1741 inline constexpr void* const _Bijection_end_ = (void* const)&_static_Bijection_end_;
1742 inline constexpr void* const _Bijection_end_safe_ = (void* const)&_static_Bijection_end_safe_;
1743#endif // DOXYGEN_SHOULD_SKIP_THIS
1744
1745
1754 template < typename T1, typename T2 >
1755 std::ostream& operator<<(std::ostream&, const Bijection< T1, T2 >& bijection);
1756
1757} /* namespace gum */
1758
1759
1760#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
1761extern template class gum::Bijection< int, int >;
1762extern template class gum::Bijection< std::string, std::string >;
1763#endif
1764
1765
1766// always include the template implementations
1768
1769#endif /* GUM_BIJECTION_H */
Class providing generic double hash tables.
A non scalar implementation of a Bijection.
Definition bijection.h:104
BijectionIteratorSafe< T1, T2 > iterator_safe
types for STL compliance
Definition bijection.h:122
BijectionImplementation(const BijectionImplementation< T1, T2, Gen > &toCopy)
Copy constructor.
T1 type1_type
types for STL compliance
Definition bijection.h:108
std::size_t size_type
types for STL compliance
Definition bijection.h:118
const T2 * type2_const_pointer
types for STL compliance
Definition bijection.h:117
BijectionIteratorSafe< T1, T2 > const_iterator_safe
types for STL compliance
Definition bijection.h:123
const iterator & end() const noexcept
Returns the unsafe iterator at the end of the gum::Bijection.
HashTable< T2, T1 * > HashTable21
Alias for more readable code.
Definition bijection.h:598
std::ptrdiff_t difference_type
types for STL compliance
Definition bijection.h:119
BijectionIterator< T1, T2 > const_iterator
types for STL compliance
Definition bijection.h:121
const_iterator cbegin() const
Returns the constant unsafe iterator at the beginning of the gum::Bjection.
T2 * type2_pointer
types for STL compliance
Definition bijection.h:116
const T1 * type1_const_pointer
types for STL compliance
Definition bijection.h:112
const T1 & type1_const_reference
types for STL compliance
Definition bijection.h:110
const T2 & type2_const_reference
types for STL compliance
Definition bijection.h:115
BijectionIterator< T1, T2 > iterator
types for STL compliance
Definition bijection.h:120
T2 type2_type
types for STL compliance
Definition bijection.h:113
BijectionImplementation(Size size, bool resize_policy)
Default constructor: creates a gum::Bijection without any association.
BijectionImplementation< T1, T2, Gen > & operator=(const BijectionImplementation< T1, T2, Gen > &toCopy)
Copy operator.
T2 & type2_reference
types for STL compliance
Definition bijection.h:114
T1 & type1_reference
types for STL compliance
Definition bijection.h:109
friend class BijectionIterator< T1, T2 >
a friend to speed-up accesses
Definition bijection.h:604
friend class Bijection< T1, T2 >
a friend to speed-up accesses
Definition bijection.h:605
BijectionImplementation< T1, T2, Gen > & operator=(BijectionImplementation< T1, T2, Gen > &&toCopy)
Move operator.
HashTable< T1, T2 * > HashTable12
Alias for more readable code.
Definition bijection.h:597
T1 * type1_pointer
types for STL compliance
Definition bijection.h:111
BijectionImplementation(BijectionImplementation< T1, T2, Gen > &&from) noexcept
Move constructor.
friend class BijectionIteratorSafe< T1, T2 >
a friend to speed-up accesses
Definition bijection.h:603
iterator begin() const
Returns the unsafe iterator at the beginning of the gum::Bijection.
friend class BijectionImplementation
a friend to speed-up accesses
Definition bijection.h:607
BijectionImplementation(std::initializer_list< std::pair< T1, T2 > > list)
Initializer list constructor.
Safe iterators for bijectionIterator.
Definition bijection.h:1240
T2 * type2_pointer
types for STL compliance
Definition bijection.h:1256
HashIter _iter_
The hashTable iterator that actually does all the job.
Definition bijection.h:1423
const T1 * type1_const_pointer
types for STL compliance
Definition bijection.h:1252
typename HashTable12::const_iterator_safe HashIter
Alias for one of the internal gum::HastTableIterator of the gum::Bijection.
Definition bijection.h:1420
BijectionIteratorGet< std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value > Getter
Dummy classes that will enable discriminate without overhead between scalars and non-scalars function...
Definition bijection.h:1266
const T1 & type1_const_reference
types for STL compliance
Definition bijection.h:1250
const T2 & second() const
Returns the second element of the current association.
T1 * type1_pointer
types for STL compliance
Definition bijection.h:1251
const T2 & type2_const_reference
types for STL compliance
Definition bijection.h:1255
T1 & type1_reference
types for STL compliance
Definition bijection.h:1249
BijectionIteratorSafe(const BijectionImplementation< T1, T2, Gen > &bijection)
Begin constructor.
T1 type1_type
types for STL compliance
Definition bijection.h:1248
const T2 * type2_const_pointer
types for STL compliance
Definition bijection.h:1257
typename std::conditional< std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value, HashTable< T1, T2 >, HashTable< T1, T2 * > >::type HashTable12
Alias for one of the internal gum::HashTable of the gum::Bijection.
Definition bijection.h:1413
std::ptrdiff_t difference_type
types for STL compliance
Definition bijection.h:1258
const T1 & first() const
Returns the first element of the current association.
T2 type2_type
types for STL compliance
Definition bijection.h:1253
std::forward_iterator_tag iterator_category
types for STL compliance
Definition bijection.h:1247
friend class BijectionImplementation
Definition bijection.h:1242
T2 & type2_reference
types for STL compliance
Definition bijection.h:1254
Unsafe iterators for bijection.
Definition bijection.h:1440
T1 * type1_pointer
types for STL compliance
Definition bijection.h:1451
T1 type1_type
types for STL compliance
Definition bijection.h:1448
typename std::conditional< std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value, HashTable< T1, T2 >, HashTable< T1, T2 * > >::type HashTable12
Alias for one of the internal gum::HashTable of the gum::Bijection.
Definition bijection.h:1607
BijectionIterator(const BijectionImplementation< T1, T2, Gen > &bijection)
Begin constructor.
typename HashTable12::const_iterator HashIter
Definition bijection.h:1611
const T1 & first() const
Returns the first element of the current association.
T2 * type2_pointer
types for STL compliance
Definition bijection.h:1456
T1 & type1_reference
types for STL compliance
Definition bijection.h:1449
T2 & type2_reference
types for STL compliance
Definition bijection.h:1454
const T2 & type2_const_reference
types for STL compliance
Definition bijection.h:1455
const T1 & type1_const_reference
types for STL compliance
Definition bijection.h:1450
BijectionIteratorGet< std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value > Getter
Dummy classes that will enable discriminate without overhead between scalars and non-scalars function...
Definition bijection.h:1466
T2 type2_type
types for STL compliance
Definition bijection.h:1453
HashIter _iter_
The hashTable iterator that actually does all the job.
Definition bijection.h:1614
std::ptrdiff_t difference_type
types for STL compliance
Definition bijection.h:1458
std::forward_iterator_tag iterator_category
types for STL compliance
Definition bijection.h:1447
const T1 * type1_const_pointer
types for STL compliance
Definition bijection.h:1452
const T2 & second() const
Returns the second element of the current association.
const T2 * type2_const_pointer
types for STL compliance
Definition bijection.h:1457
friend class BijectionImplementation
Definition bijection.h:1442
Set of pairs of elements with fast search for both elements.
Definition bijection.h:1640
const T1 * type1_const_pointer
types for STL compliance
Definition bijection.h:1648
BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value > Implementation
The Implementation of this gum::Bijection.
Definition bijection.h:1663
T2 & type2_reference
types for STL compliance
Definition bijection.h:1650
T2 * type2_pointer
types for STL compliance
Definition bijection.h:1652
Bijection< const DiscreteVariable *, const DiscreteVariable * > & operator=(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &toCopy)
Bijection(Size size=HashTableConst::default_size, bool resize_policy=HashTableConst::default_resize_policy)
Default constructor: creates a gum::Bijection without any association.
const T1 & type1_const_reference
types for STL compliance
Definition bijection.h:1646
BijectionIteratorSafe< T1, T2 > iterator_safe
types for STL compliance
Definition bijection.h:1658
BijectionIteratorSafe< T1, T2 > const_iterator_safe
types for STL compliance
Definition bijection.h:1659
T2 type2_type
types for STL compliance
Definition bijection.h:1649
T1 * type1_pointer
types for STL compliance
Definition bijection.h:1647
std::ptrdiff_t difference_type
types for STL compliance
Definition bijection.h:1655
const T2 * type2_const_pointer
types for STL compliance
Definition bijection.h:1653
T1 type1_type
types for STL compliance
Definition bijection.h:1644
const T2 & type2_const_reference
types for STL compliance
Definition bijection.h:1651
T1 & type1_reference
types for STL compliance
Definition bijection.h:1645
BijectionIterator< T1, T2 > const_iterator
types for STL compliance
Definition bijection.h:1657
BijectionIterator< T1, T2 > iterator
types for STL compliance
Definition bijection.h:1656
std::size_t size_type
types for STL compliance
Definition bijection.h:1654
The class for generic Hash Tables.
Definition hashTable.h:640
A lightweight wrapper around a pointer providing an optional-like API for references (not supported b...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Class hash tables iterators.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.
static const T & op_second(const T &x)
Returns a reference.
Dummy classes for discriminating scalars and non-scalars operators and -> wihtout any overhead.
Definition bijection.h:1196
static const T & op_second(const T *x)
Returns a refeence over a pointer.
static constexpr Size default_size
The default number of slots in hashtables.
Definition hashTable.h:102
static constexpr bool default_resize_policy
A Boolean indicating whether inserting too many values into the hashtable makes it resize itself auto...
Definition hashTable.h:116
std::ostream & operator<<(std::ostream &out, const TiXmlNode &base)
Definition tinyxml.cpp:1516