33 #ifndef GUM_BIJECTION_H 34 #define GUM_BIJECTION_H 36 #include <initializer_list> 40 #include <type_traits> 46 #ifndef DOXYGEN_SHOULD_SKIP_THIS 48 template <
typename T1,
typename T2 >
49 class BijectionIteratorSafe;
50 template <
typename T1,
typename T2 >
51 class BijectionIterator;
52 template <
typename T1,
typename T2,
typename Alloc,
bool >
53 class BijectionImplementation;
54 template <
typename T1,
typename T2,
typename Alloc >
84 template <
typename T1,
typename T2,
typename Alloc,
bool Gen >
107 typename Alloc::template rebind< std::pair< T1, T2* > >::other;
109 typename Alloc::template rebind< std::pair< T2, T1* > >::other;
139 template <
typename OtherAlloc >
177 template <
typename OtherAlloc >
484 const T2& second(const T1&
first) const;
535 void insert(T1&& first, T2&& second);
547 template < typename... Args >
561 bool empty() const noexcept;
650 template < typename TT1, typename TT2, typename A,
bool >
674 template < typename OtherAlloc >
694 #ifndef DOXYGEN_SHOULD_SKIP_THIS 723 template <
typename T1,
typename T2,
typename Alloc >
724 class BijectionImplementation< T1, T2, Alloc, true > {
746 using allocator12_type =
747 typename Alloc::template rebind< std::pair< T1, T2 > >::other;
748 using allocator21_type =
749 typename Alloc::template rebind< std::pair< T2, T1 > >::other;
779 template <
typename OtherAlloc >
817 template <
typename OtherAlloc >
1105 const T1&
first(T2 second)
const;
1124 const T2&
second(T1 first)
const;
1164 void insert(T1 first, T2 second);
1176 template <
typename... Args >
1190 bool empty()
const noexcept;
1278 friend class Bijection< T1, T2, Alloc >;
1279 template <
typename TT1,
typename TT2,
typename A,
bool >
1280 friend class BijectionImplementation;
1303 template <
typename OtherAlloc >
1312 void __insert(
const T1 first,
const T2 second);
1329 template <
typename T1,
typename T2,
typename Alloc,
bool >
1330 friend class BijectionImplementation;
1362 template <
bool gen >
1369 template <
typename T >
1391 template <
typename T >
1410 template <
typename T1,
typename T2 >
1412 template <
typename TT1,
typename TT2,
typename Alloc,
bool >
1413 friend class BijectionImplementation;
1438 && std::is_scalar< T2 >::value >;
1446 template <
typename Alloc,
bool Gen >
1465 template < typename Alloc >
1569 const T1& first() const;
1577 const T2& second() const;
1584 std::is_scalar< T1 >::value &&
std::is_scalar< T2 >::value,
1608 template < typename T1, typename T2 >
1610 template <
typename TT1,
typename TT2,
typename Alloc,
bool >
1611 friend class BijectionImplementation;
1636 && std::is_scalar< T2 >::value >;
1642 template <
typename Alloc,
bool Gen >
1655 BijectionIterator() noexcept;
1661 template < typename Alloc >
1662 BijectionIterator(const
Bijection< T1, T2, Alloc >& bijection);
1668 BijectionIterator(const BijectionIterator< T1, T2 >& from);
1674 BijectionIterator(BijectionIterator< T1, T2 >&& from) noexcept;
1679 ~BijectionIterator() noexcept;
1692 BijectionIterator< T1, T2 >&
1693 operator=(const BijectionIterator< T1, T2 >& toCopy);
1700 BijectionIterator< T1, T2 >&
1701 operator=(BijectionIterator< T1, T2 >&& toMove) noexcept;
1710 BijectionIterator< T1, T2 >& operator++() noexcept;
1723 BijectionIterator< T1, T2 >& operator+=(
Size nb) noexcept;
1733 BijectionIterator< T1, T2 > operator+(
Size nb) noexcept;
1740 bool operator!=(const BijectionIterator< T1, T2 >& toCompare) const noexcept;
1747 bool operator==(const BijectionIterator< T1, T2 >& toCompare) const noexcept;
1761 const T1& first() const;
1769 const T2& second() const;
1776 std::is_scalar< T1 >::value &&
std::is_scalar< T2 >::value,
1804 template < typename T1, typename T2, typename Alloc =
std::allocator< T2 > >
1806 : public BijectionImplementation< T1,
1809 std::is_scalar< T1 >::value
1810 &&
std::is_scalar< T2 >::value > {
1838 BijectionImplementation< T1,
1841 std::is_scalar< T1 >::value
1842 && std::is_scalar< T2 >::value >;
1863 Bijection(std::initializer_list< std::pair< T1, T2 > > list);
1876 template <
typename OtherAlloc >
1909 template <
typename OtherAlloc >
1931 template <
typename T1,
typename T2,
typename Alloc >
1938 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1939 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1943 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1944 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
void insert(const T1 &first, const T2 &second)
Inserts a new association in the gum::Bijection.
friend class BijectionImplementation
a friend to speed-up accesses
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
void __copy(const HashTable< T1, T2 *, OtherAlloc > &source)
A function that performs a complete copy of another gum::Bijection.
void emplace(Args &&... args)
Emplace a new element in the gum::Bijection.
void clear()
Removes all the associations from the gum::Bijection.
const GUM_SCALAR & type2_const_reference
BijectionImplementation< T1, T2, Alloc, Gen > & operator=(const BijectionImplementation< T1, T2, Alloc, Gen > &toCopy)
Copy operator.
const NodeId * type1_const_pointer
Dummy classes for discriminating scalars and non-scalars operators and -> wihtout any overhead...
const T1 & first(const T2 &second) const
Returns the first value of a pair given its second value.
std::forward_iterator_tag iterator_category
types for STL compliance
Idx type1_type
types for STL compliance
const Idx * type1_const_pointer
void eraseFirst(const T1 &first)
Erases an association containing the given first element.
const const std::string * & type2_const_reference
Safe iterators for bijectionIterator.
iterator begin() const
Returns the unsafe iterator at the beginning of the gum::Bijection.
typename std::allocator< const std::string *> ::template rebind< std::pair< Idx, const std::string * * > >::other allocator12_type
static constexpr Size default_size
The default number of slots in hashtables.
typename std::conditional< std::is_scalar< int >::value &&std::is_scalar< int >::value, HashTable< int, int, std::allocator< std::pair< int, int > > >, HashTable< int, int *, std::allocator< std::pair< int, int * > > > >::type HashTable12
Alias for one of the internal gum::HashTable of the gum::Bijection.
const int * type1_const_pointer
const_iterator cbegin() const
Returns the constant unsafe iterator at the beginning of the gum::Bjection.
GUM_SCALAR & type2_reference
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
static const iterator_safe & endSafe4Statics()
Returns the safe end iterator for other classes' statics.
void resize(Size new_size)
Manually resize the gum::Bijection.
const const_iterator_safe & cendSafe() const noexcept
Returns the constant safe iterator at the end of the gum::Bijection.
std::ptrdiff_t difference_type
bool existsSecond(const T2 &second) const
Returns true if second is the second element in a pair in the gum::Bijection.
std::allocator< const std::string *> allocator_type
static INLINE const T & op_second(const T *x)
Returns a refeence over a pointer.
void eraseSecond(const T2 &second)
Erases an association containing the given second element.
BijectionIteratorSafe< T1, T2 > const_iterator_safe
types for STL compliance
Size capacity() const noexcept
Returns the number of hashtables slots used.
bool existsFirst(const T1 &first) const
Returns true if first is the first element in a pair in the gum::Bijection.
GUM_SCALAR * type2_pointer
A class which creates the static iterator used by gim::Bijections.
const iterator & end() const noexcept
Returns the unsafe iterator at the end of the gum::Bijection.
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map's DAG in output using the Graphviz-dot format.
const T1 & firstWithDefault(const T2 &second, const T1 &default_val) const
Returns the first value of a pair given its second value or default_val if second is unfound...
bool empty() const noexcept
Returns true if the gum::Bijection doesn't contain any association.
const T2 & secondWithDefault(const T1 &second, const T2 &default_val) const
Returns the second value of a pair given its first value or default_val if first is unfound...
const GUM_SCALAR * type2_const_pointer
std::ptrdiff_t difference_type
HashTable12 __firstToSecond
The gum::HashTable associating T2 objects to T1 objects.
const NodeId & type1_const_reference
Unsafe iterators for bijection.
static constexpr bool default_resize_policy
A Boolean indicating whether inserting too many values into the hashtable makes it resize itself auto...
typename std::allocator< std::size_t > ::template rebind< std::size_t * >::other allocator2_type
const std::string * & type2_reference
Set of pairs of elements with fast search for both elements.
typename std::allocator< std::size_t > ::template rebind< NodeId * >::other allocator1_type
const const_iterator & cend() const noexcept
Returns the constant iterator at the end of the gum::Bijection.
static const BijectionIterator< int, int > * __BijectionIterEnd
The unsafe iterator used by everyone.
Size size() const noexcept
Returns the number of associations stored within the gum::Bijection.
iterator_safe beginSafe() const
Returns the safe iterator at the beginning of the gum::Bijection.
~BijectionImplementation()
Destructor.
typename HashTable12::const_iterator HashIter
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
typename std::conditional< std::is_scalar< NodeId >::value &&std::is_scalar< GUM_SCALAR >::value, HashTable< NodeId, GUM_SCALAR, std::allocator< std::pair< NodeId, GUM_SCALAR > > >, HashTable< NodeId, GUM_SCALAR *, std::allocator< std::pair< NodeId, GUM_SCALAR * > > > >::type HashTable12
Alias for one of the internal gum::HashTable of the gum::Bijection.
static INLINE const T & op_second(const T &x)
Returns a reference.
BijectionIterator< T1, T2 > const_iterator
types for STL compliance
static const BijectionIteratorSafe< int, int > * __BijectionIterEndSafe
The safe iterator used by everyone.
const Idx & type1_const_reference
const int * type2_const_pointer
std::string toString() const
Returns a friendly representatin of the gum::Bijection.
const const std::string * * type2_const_pointer
bool resizePolicy() const noexcept
Returns true if the resize policy is automatic.
const iterator_safe & endSafe() const noexcept
Returns the safe iterator at the end of the gum::Bijection.
typename HashTable12::const_iterator_safe HashIter
Alias for one of the internal gum::HastTableIterator of the gum::Bijection.
const int & type2_const_reference
std::forward_iterator_tag iterator_category
types for STL compliance
typename std::allocator< const std::string *> ::template rebind< std::pair< const std::string *, Idx * > >::other allocator21_type
std::size_t Size
In aGrUM, hashed values are unsigned long int.
static const iterator & end4Statics()
Returns the unsafe end iterator for other classes' statics.
const int & type1_const_reference
HashTable21 __secondToFirst
The gum::HashTable associating T1 objects to T2 objects.
std::ptrdiff_t difference_type
const std::string * type2_type
const_iterator_safe cbeginSafe() const
Returns the constant safe iterator at the begining of the gum::Bijection.
HashTable12::value_type * __insert(const T1 &first, const T2 &second)
Inserts a new association into the gum::Bijection.
void setResizePolicy(const bool new_policy) noexcept
Change the gum::Bijection resizing policy.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
A non scalar implementation of a Bijection.
const std::string * * type2_pointer