52#ifndef GUM_BIJECTION_H
53#define GUM_BIJECTION_H
61#include <initializer_list>
66#ifndef DOXYGEN_SHOULD_SKIP_THIS
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 >
103 template <
typename T1,
typename T2,
bool Gen >
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 >)
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 >)
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 >)
503 template < typename... Args >
606 template < typename TT1, typename TT2,
bool >
648#ifndef DOXYGEN_SHOULD_SKIP_THIS
676 template <
typename T1,
typename T2 >
1047 template <
typename... Args >
1061 bool empty()
const noexcept;
1150 template <
typename TT1,
typename TT2,
bool >
1195 template <
bool gen >
1202 template <
typename T >
1222 template <
typename T >
1239 template <
typename T1,
typename T2 >
1241 template <
typename TT1,
typename TT2,
bool >
1275 template <
bool Gen >
1289#ifndef DOXYGEN_SHOULD_SKIP_THIS
1400 const T1&
first() const;
1408 const T2&
second() const;
1415 typename
std::conditional<
std::is_scalar< T1 >::value &&
std::is_scalar< T2 >::value,
1439 template < typename T1, typename T2 >
1441 template <
typename TT1,
typename TT2,
bool >
1473 template <
bool Gen >
1487#ifndef DOXYGEN_SHOULD_SKIP_THIS
1594 const T1&
first() const;
1602 const T2&
second() const;
1609 typename
std::conditional<
std::is_scalar< T1 >::value &&
std::is_scalar< T2 >::value,
1636 template < typename T1, typename T2 >
1640 std::is_scalar< T1 >::value &&
std::is_scalar< T2 >::value > {
1666 std::is_scalar< T1 >::value && std::is_scalar< T2 >::value >;
1687 Bijection(std::initializer_list< std::pair< T1, T2 > > list);
1729#ifndef DOXYGEN_SHOULD_SKIP_THIS
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_;
1754 template <
typename T1,
typename T2 >
1760#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
Class providing generic double hash tables.
A non scalar implementation of a Bijection.
void emplace(Args &&... args)
BijectionIteratorSafe< T1, T2 > iterator_safe
types for STL compliance
void setResizePolicy(const bool new_policy) noexcept
BijectionImplementation(const BijectionImplementation< T1, T2, Gen > &toCopy)
Copy constructor.
T1 type1_type
types for STL compliance
optional_ref< const T2 > trySecond(const T1 &first) const
std::size_t size_type
types for STL compliance
const T2 * type2_const_pointer
types for STL compliance
bool resizePolicy() const noexcept
BijectionIteratorSafe< T1, T2 > const_iterator_safe
types for STL compliance
const iterator & end() const noexcept
Returns the unsafe iterator at the end of the gum::Bijection.
HashTable12 _firstToSecond_
const iterator_safe & endSafe() const noexcept
HashTable< T2, T1 * > HashTable21
Alias for more readable code.
std::ptrdiff_t difference_type
types for STL compliance
BijectionIterator< T1, T2 > const_iterator
types for STL compliance
const_iterator cbegin() const
Returns the constant unsafe iterator at the beginning of the gum::Bjection.
T2 * type2_pointer
types for STL compliance
const T1 * type1_const_pointer
types for STL compliance
HashTable21 _secondToFirst_
std::string toString() const
const T1 & type1_const_reference
types for STL compliance
const T2 & type2_const_reference
types for STL compliance
BijectionIterator< T1, T2 > iterator
types for STL compliance
T2 type2_type
types for STL compliance
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.
const_iterator_safe cbeginSafe() const
T2 & type2_reference
types for STL compliance
const T2 & second(const T1 &first) const
T1 & type1_reference
types for STL compliance
optional_ref< const T1 > tryFirst(const T2 &second) const
bool empty() const noexcept
friend class BijectionIterator< T1, T2 >
a friend to speed-up accesses
void insert(const T1 &first, const T2 &second)
void resize(Size new_size)
const T2 & secondWithDefault(const T1 &second, const T2 &default_val) const
HashTable12::value_type * _insert_(const T1 &first, const T2 &second)
friend class Bijection< T1, T2 >
a friend to speed-up accesses
Size capacity() const noexcept
bool existsSecond(const T2 &second) const
const T1 & first(const T2 &second) const
void _copy_(const HashTable< T1, T2 * > &source)
Size size() const noexcept
~BijectionImplementation()
Destructor.
BijectionImplementation< T1, T2, Gen > & operator=(BijectionImplementation< T1, T2, Gen > &&toCopy)
Move operator.
HashTable< T1, T2 * > HashTable12
Alias for more readable code.
T1 * type1_pointer
types for STL compliance
BijectionImplementation(BijectionImplementation< T1, T2, Gen > &&from) noexcept
Move constructor.
void eraseFirst(const T1 &first)
iterator_safe beginSafe() const
void eraseSecond(const T2 &second)
const const_iterator & cend() const noexcept
friend class BijectionIteratorSafe< T1, T2 >
a friend to speed-up accesses
iterator begin() const
Returns the unsafe iterator at the beginning of the gum::Bijection.
friend class BijectionImplementation
a friend to speed-up accesses
BijectionImplementation(std::initializer_list< std::pair< T1, T2 > > list)
Initializer list constructor.
bool existsFirst(const T1 &first) const
const T1 & firstWithDefault(const T2 &second, const T1 &default_val) const
const const_iterator_safe & cendSafe() const noexcept
Safe iterators for bijectionIterator.
T2 * type2_pointer
types for STL compliance
HashIter _iter_
The hashTable iterator that actually does all the job.
const T1 * type1_const_pointer
types for STL compliance
typename HashTable12::const_iterator_safe HashIter
Alias for one of the internal gum::HastTableIterator of the gum::Bijection.
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...
const T1 & type1_const_reference
types for STL compliance
const T2 & second() const
Returns the second element of the current association.
T1 * type1_pointer
types for STL compliance
const T2 & type2_const_reference
types for STL compliance
T1 & type1_reference
types for STL compliance
BijectionIteratorSafe(const BijectionImplementation< T1, T2, Gen > &bijection)
Begin constructor.
T1 type1_type
types for STL compliance
const T2 * type2_const_pointer
types for STL compliance
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.
std::ptrdiff_t difference_type
types for STL compliance
const T1 & first() const
Returns the first element of the current association.
T2 type2_type
types for STL compliance
std::forward_iterator_tag iterator_category
types for STL compliance
friend class BijectionImplementation
T2 & type2_reference
types for STL compliance
Unsafe iterators for bijection.
T1 * type1_pointer
types for STL compliance
T1 type1_type
types for STL compliance
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.
BijectionIterator(const BijectionImplementation< T1, T2, Gen > &bijection)
Begin constructor.
typename HashTable12::const_iterator HashIter
const T1 & first() const
Returns the first element of the current association.
T2 * type2_pointer
types for STL compliance
T1 & type1_reference
types for STL compliance
T2 & type2_reference
types for STL compliance
const T2 & type2_const_reference
types for STL compliance
const T1 & type1_const_reference
types for STL compliance
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...
T2 type2_type
types for STL compliance
HashIter _iter_
The hashTable iterator that actually does all the job.
std::ptrdiff_t difference_type
types for STL compliance
std::forward_iterator_tag iterator_category
types for STL compliance
const T1 * type1_const_pointer
types for STL compliance
const T2 & second() const
Returns the second element of the current association.
const T2 * type2_const_pointer
types for STL compliance
friend class BijectionImplementation
Set of pairs of elements with fast search for both elements.
const T1 * type1_const_pointer
types for STL compliance
BijectionImplementation< T1, T2, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value > Implementation
The Implementation of this gum::Bijection.
T2 & type2_reference
types for STL compliance
T2 * type2_pointer
types for STL compliance
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
BijectionIteratorSafe< T1, T2 > iterator_safe
types for STL compliance
BijectionIteratorSafe< T1, T2 > const_iterator_safe
types for STL compliance
T2 type2_type
types for STL compliance
T1 * type1_pointer
types for STL compliance
std::ptrdiff_t difference_type
types for STL compliance
const T2 * type2_const_pointer
types for STL compliance
T1 type1_type
types for STL compliance
const T2 & type2_const_reference
types for STL compliance
T1 & type1_reference
types for STL compliance
BijectionIterator< T1, T2 > const_iterator
types for STL compliance
BijectionIterator< T1, T2 > iterator
types for STL compliance
std::size_t size_type
types for STL compliance
The class for generic Hash Tables.
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.
Class hash tables iterators.
gum is the global namespace for all aGrUM entities
static const T & op_second(const T &x)
Returns a reference.
Dummy classes for discriminating scalars and non-scalars operators and -> wihtout any overhead.
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.
static constexpr bool default_resize_policy
A Boolean indicating whether inserting too many values into the hashtable makes it resize itself auto...
std::ostream & operator<<(std::ostream &out, const TiXmlNode &base)