![]() |
aGrUM
0.14.2
|
Representation of a setA Set is a structure that contains arbitrary elements. More...
#include <agrum/core/set.h>
Public Member Functions | |
template<typename OtherAlloc > | |
INLINE | Set (const Set< Key, OtherAlloc > &s) |
template<typename OtherAlloc > | |
INLINE bool | operator!= (const Set< Key, OtherAlloc > &s2) const |
template<typename OtherAlloc > | |
INLINE bool | isSubsetOf (const Set< Key, OtherAlloc > &s) const |
template<typename OtherAlloc > | |
INLINE bool | isSupersetOf (const Set< Key, OtherAlloc > &s) const |
template<typename... Args> | |
INLINE void | emplace (Args &&... args) |
Constructors / Destructors | |
Set (Size capacity=HashTableConst::default_size, bool resize_policy=true) | |
Default constructor. More... | |
Set (std::initializer_list< Key > list) | |
Initializer list constructor. More... | |
Set (const Set< Key, Alloc > &aHT) | |
Copy constructor. More... | |
template<typename OtherAlloc > | |
Set (const Set< Key, OtherAlloc > &aHT) | |
Generalized copy constructor. More... | |
Set (Set< Key, Alloc > &&aHT) | |
Move constructor. More... | |
~Set () | |
Class destructor. More... | |
Operators | |
Set< Key, Alloc > & | operator= (const Set< Key, Alloc > &from) |
Copy operator. More... | |
template<typename OtherAlloc > | |
Set< Key, Alloc > & | operator= (const Set< Key, OtherAlloc > &from) |
Generalized copy operator. More... | |
Set< Key, Alloc > & | operator= (Set< Key, Alloc > &&from) |
Move operator. More... | |
template<typename OtherAlloc > | |
bool | operator== (const Set< Key, OtherAlloc > &s2) const |
Mathematical equality between two sets. More... | |
template<typename OtherAlloc > | |
bool | operator!= (const Set< Key, OtherAlloc > &s2) const |
Mathematical inequality between two sets. More... | |
template<typename OtherAlloc > | |
const Set< Key, Alloc > & | operator*= (const Set< Key, OtherAlloc > &s2) |
Intersection update operator. More... | |
template<typename OtherAlloc > | |
Set< Key, Alloc > | operator* (const Set< Key, OtherAlloc > &s2) const |
Intersection operator. More... | |
template<typename OtherAlloc > | |
const Set< Key, Alloc > & | operator+= (const Set< Key, OtherAlloc > &s2) |
Union update operator. More... | |
template<typename OtherAlloc > | |
Set< Key, Alloc > | operator+ (const Set< Key, OtherAlloc > &s2) const |
Union operator. More... | |
template<typename OtherAlloc > | |
Set< Key, Alloc > | operator- (const Set< Key, OtherAlloc > &s2) const |
Disjunction operator. More... | |
Set< Key, Alloc > & | operator<< (const Key &k) |
Adds a new element to the set (alias for insert). More... | |
Set< Key, Alloc > & | operator<< (Key &&k) |
Adds a new element to the set (alias for insert). More... | |
Set< Key, Alloc > & | operator>> (const Key &k) |
Removes an element from the set (alias for erase). More... | |
Accessors / Modifiers | |
void | insert (const Key &k) |
Inserts a new element into the set. More... | |
void | insert (Key &&k) |
Inserts a new element into the set. More... | |
template<typename... Args> | |
void | emplace (Args &&... args) |
Emplace a new element in the set. More... | |
void | erase (const Key &k) |
Erases an element from the set. More... | |
void | erase (const iterator_safe &k) |
Erases an element from the set. More... | |
void | clear () |
Removes all the elements, if any, from the set. More... | |
Size | size () const noexcept |
Returns the number of elements in the set. More... | |
bool | contains (const Key &k) const |
Indicates whether a given elements belong to the set. More... | |
template<typename OtherAlloc > | |
bool | isSubsetOf (const Set< Key, OtherAlloc > &s) const |
template<typename OtherAlloc > | |
bool | isSupersetOf (const Set< Key, OtherAlloc > &s) const |
bool | exists (const Key &k) const |
Indicates whether a given elements belong to the set. More... | |
bool | empty () const noexcept |
Indicates whether the set is the empty set. More... | |
std::string | toString () const |
Prints the content of the set. More... | |
Fine tuning | |
Size | capacity () const |
Returns the capacity of the underlying hash table containing the set. More... | |
void | resize (Size new_capacity) |
Changes the size of the underlying hash table containing the set. More... | |
void | setResizePolicy (const bool new_policy) |
Enables the user to change dynamically the resizing policy of the underlying hash table. More... | |
bool | resizePolicy () const |
Returns the current resizing policy of the underlying hash table. More... | |
Mapper | |
template<typename NewKey , typename NewAlloc = typename Alloc::template rebind< NewKey >::other> | |
HashTable< Key, NewKey, NewAlloc > | hashMap (NewKey(*f)(const Key &), Size capacity=0) const |
Creates a hashtable of NewKey from the set. More... | |
template<typename NewKey , typename NewAlloc = typename Alloc::template rebind< NewKey >::other> | |
HashTable< Key, NewKey, NewAlloc > | hashMap (const NewKey &val, Size size=0) const |
Creates a hash table of NewKey from the set. More... | |
template<typename NewKey , typename NewAlloc = typename Alloc::template rebind< NewKey >::other> | |
List< NewKey, NewAlloc > | listMap (NewKey(*f)(const Key &)) const |
A method to create a List of NewKey from the set. More... | |
Public Types | |
using | value_type = Key |
Types for STL compliance. More... | |
using | reference = Key & |
Types for STL compliance. More... | |
using | const_reference = const Key & |
Types for STL compliance. More... | |
using | pointer = Key * |
Types for STL compliance. More... | |
using | const_pointer = const Key * |
Types for STL compliance. More... | |
using | size_type = std::size_t |
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 = SetIterator< Key > |
Types for STL compliance. More... | |
using | const_iterator = SetIterator< Key > |
Types for STL compliance. More... | |
using | iterator_safe = SetIteratorSafe< Key > |
Types for STL compliance. More... | |
using | const_iterator_safe = SetIteratorSafe< Key > |
Types for STL compliance. More... | |
Friends | |
class | SetIterator< Key > |
Friends to speed up access. More... | |
class | SetIteratorSafe< Key > |
Friends to speed up access. More... | |
template<typename K , typename A > | |
class | Set |
Friends to speed up access. More... | |
Iterators | |
iterator_safe | beginSafe () const |
The usual safe begin iterator to parse the set. More... | |
const_iterator_safe | cbeginSafe () const |
The usual safe begin iterator to parse the set. More... | |
const iterator_safe & | endSafe () const noexcept |
The usual safe end iterator to parse the set. More... | |
const const_iterator_safe & | cendSafe () const noexcept |
The usual safe end iterator to parse the set. More... | |
iterator | begin () const |
The usual unsafe begin iterator to parse the set. More... | |
const_iterator | cbegin () const |
The usual unsafe begin iterator to parse the set. More... | |
const iterator & | end () const noexcept |
The usual unsafe end iterator to parse the set. More... | |
const const_iterator & | cend () const noexcept |
The usual unsafe end iterator to parse the set. More... | |
static const iterator & | end4Statics () |
Returns the end iterator for other classes' statics (read the detailed description of this method). More... | |
static const const_iterator & | constEnd4Statics () |
Returns the end iterator for other classes' statics (read the detailed description of this method). More... | |
static const iterator_safe & | endSafe4Statics () |
Returns the end iterator for other classes' statics (read the detailed description of this method). More... | |
static const const_iterator_safe & | constEndSafe4Statics () |
Returns the end iterator for other classes' statics (read the detailed description of this method). More... | |
Representation of a set
A Set is a structure that contains arbitrary elements.
Note that, as in mathematics, an element cannot appear twice in a given set. Sets have unsafe and safe iterators. The safe iterators (SetIteratorSafe<> a.k.a. Set<>::iterator_safe are slightly slower than the unsafe ones (SetIterator<> a.k.a. Set<>::iterator) but they guarantee that even if they point to a deleted element, using their operators ++ or * cannot produce a segfault. In such cases, they simply raise an exception. On the contrary, unsafe iterators should never be used on elements that can be deleted because, as in the STL, they will most probably produce a segfault.
Key | The elements type. |
Alloc | The elements allocator. |
using gum::Set< Key, Alloc >::allocator_type = Alloc |
using gum::Set< Key, Alloc >::const_iterator = SetIterator< Key > |
using gum::Set< Key, Alloc >::const_iterator_safe = SetIteratorSafe< Key > |
using gum::Set< Key, Alloc >::const_pointer = const Key* |
using gum::Set< Key, Alloc >::const_reference = const Key& |
using gum::Set< Key, Alloc >::difference_type = std::ptrdiff_t |
using gum::Set< Key, Alloc >::iterator = SetIterator< Key > |
using gum::Set< Key, Alloc >::iterator_safe = SetIteratorSafe< Key > |
using gum::Set< Key, Alloc >::value_type = Key |
|
explicit |
Default constructor.
Sets rely on hashtables to store their items. The optional parameters of this constructor enable a fine memory management of these hashtables.
capacity | The number of slots allocated to the hashtable (see the HashTable default constructor) |
resize_policy | Enables the hashtable to resize itself automatically when its number of elements is sufficiently high that it induces slow retrievals of elements. |
Definition at line 316 of file set_tpl.h.
INLINE gum::Set< Key, Alloc >::Set | ( | std::initializer_list< Key > | list | ) |
Initializer list constructor.
list | The initializer list. |
Definition at line 330 of file set_tpl.h.
INLINE gum::Set< Key, Alloc >::Set | ( | const Set< Key, Alloc > & | aHT | ) |
INLINE gum::Set< Key, Alloc >::Set | ( | Set< Key, Alloc > && | aHT | ) |
Class destructor.
|
private |
Convert a hash table into a set of keys.
INLINE gum::Set< Key, Alloc >::Set | ( | const Set< Key, OtherAlloc > & | s | ) |
INLINE Set< Key, Alloc >::iterator gum::Set< Key, Alloc >::begin | ( | ) | const |
The usual unsafe begin iterator to parse the set.
Definition at line 514 of file set_tpl.h.
Referenced by gum::StaticTriangulation::__computeMaxPrimeMergings(), gum::StaticTriangulation::__triangulate(), gum::prm::StructuredInference< GUM_SCALAR >::_marginal(), gum::BarrenNodesFinder::barrenNodes(), and gum::prm::eliminateNode().
INLINE Set< Key, Alloc >::iterator_safe gum::Set< Key, Alloc >::beginSafe | ( | ) | const |
The usual safe begin iterator to parse the set.
Definition at line 485 of file set_tpl.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::__updateNodeSet(), gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::LeafAggregator::addLeaf(), gum::BarrenNodesFinder::barrenNodes(), gum::ArcGraphPart::eraseChildren(), gum::ArcGraphPart::eraseParents(), gum::LeafAggregator::removeLeaf(), gum::VariableSelector::select(), gum::ArcGraphPart::unvirtualizedEraseChildren(), gum::ArcGraphPart::unvirtualizedEraseParents(), gum::IMDDI< AttributeSelection, isScalar >::updateGraph(), and gum::LeafAggregator::updateLeaf().
Returns the capacity of the underlying hash table containing the set.
The method runs in constant time.
Definition at line 543 of file set_tpl.h.
Referenced by gum::Set< gum::Potential< GUM_SCALAR > * >::capacity(), and gum::Set< gum::Potential< GUM_SCALAR > * >::operator=().
INLINE Set< Key, Alloc >::const_iterator gum::Set< Key, Alloc >::cbegin | ( | ) | const |
The usual unsafe begin iterator to parse the set.
Definition at line 521 of file set_tpl.h.
Referenced by gum::DefaultPartialOrderedEliminationSequenceStrategy::nextNodeToEliminate().
INLINE Set< Key, Alloc >::const_iterator_safe gum::Set< Key, Alloc >::cbeginSafe | ( | ) | const |
The usual safe begin iterator to parse the set.
Definition at line 492 of file set_tpl.h.
Referenced by gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_updateNode(), and gum::NodeDatabase< AttributeSelection, isScalar >::NodeDatabase().
|
noexcept |
The usual unsafe end iterator to parse the set.
Definition at line 536 of file set_tpl.h.
Referenced by gum::DefaultPartialOrderedEliminationSequenceStrategy::nextNodeToEliminate().
|
noexcept |
The usual safe end iterator to parse the set.
Definition at line 507 of file set_tpl.h.
Referenced by gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_updateNode(), and gum::NodeDatabase< AttributeSelection, isScalar >::NodeDatabase().
INLINE void gum::Set< Key, Alloc >::clear | ( | ) |
Removes all the elements, if any, from the set.
Definition at line 372 of file set_tpl.h.
Referenced by gum::MarginalTargetedInference< GUM_SCALAR >::__setAllMarginalTargets(), gum::IMDDI< AttributeSelection, isScalar >::__updateNodeSet(), gum::MarginalTargetedInference< GUM_SCALAR >::_setTargetedMode(), gum::PartialOrderedEliminationSequenceStrategy::clear(), gum::StaticTriangulation::clear(), gum::Set< gum::Potential< GUM_SCALAR > * >::clear(), gum::ArcGraphPart::clearArcs(), gum::EdgeGraphPart::clearEdges(), gum::BayesNetInference< GUM_SCALAR >::eraseAllEvidence(), gum::MarginalTargetedInference< GUM_SCALAR >::eraseAllTargets(), gum::JointTargetedInference< GUM_SCALAR >::jointMutualInformation(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::PartialOrderedEliminationSequenceStrategy::setPartialOrder(), gum::ITI< AttributeSelection, isScalar >::updateGraph(), and gum::LeafAggregator::updateLeaf().
|
static |
Returns the end iterator for other classes' statics (read the detailed description of this method).
To reduce the Sets memory consumption (which are heavily used in aGrUM) while allowing fast for(iter=begin(); iter!=end();++iter) loops, end iterators are created just once as a static member of a non-template Set. While this scheme is efficient and it works quite effectively when manipulating sets, it has a drawback: other classes with static members using the Set's end() iterator may fail to work due to the well known "static initialization order fiasco" (see Marshall Cline's C++ FAQ for more details about this C++ feature). OK, so what is the problem? Consider a class, say X, containing a Set that stores all its elements in a convenient way. To reduce memory consumption, X::end iterator is a static member that is initialized with a Set::end iterator. If the compiler decides to initialize X::end before initializing Set::end, then X::end will be in an incoherent state. Unfortunately, we cannot know for sure in which order static members will be initialized (the order is a compiler's decision). Hence, we shall enfore the fact that Set::end is initialized before X::end. Using method Set::end4Statics will ensure this fact: it uses the C++ "construct on first use" idiom (see the C++ FAQ) that ensures that the order fiasco is avoided. More precisely, end4Statics uses a global variable that is the very end iterator used by all Sets. Now, this induces a small overhead. So, we also provide a Set::end() method that returns the Set::end iterator without this small overhead, but assuming that function end4Statics has already been called once (which is always the case) when a Set has been created.
So, to summarize: when initializing static members, use constEnd4Statics() rather than cend(). In all the other cases, use simply the usual method cend().
Definition at line 309 of file set_tpl.h.
|
static |
Returns the end iterator for other classes' statics (read the detailed description of this method).
To reduce the Sets memory consumption (which are heavily used in aGrUM) while allowing fast for(iter=begin(); iter!=end();++iter) loops, end iterators are created just once as a static member of a non-template Set. While this scheme is efficient and it works quite effectively when manipulating sets, it has a drawback: other classes with static members using the Set's end() iterator may fail to work due to the well known "static initialization order fiasco" (see Marshall Cline's C++ FAQ for more details about this C++ feature). OK, so what is the problem? Consider a class, say X, containing a Set that stores all its elements in a convenient way. To reduce memory consumption, X::end iterator is a static member that is initialized with a Set::end iterator. If the compiler decides to initialize X::end before initializing Set::end, then X::end will be in an incoherent state. Unfortunately, we cannot know for sure in which order static members will be initialized (the order is a compiler's decision). Hence, we shall enfore the fact that Set::end is initialized before X::end. Using method Set::end4Statics will ensure this fact: it uses the C++ "construct on first use" idiom (see the C++ FAQ) that ensures that the order fiasco is avoided. More precisely, end4Statics uses a global variable that is the very end iterator used by all Sets. Now, this induces a small overhead. So, we also provide a Set::end() method that returns the Set::end iterator without this small overhead, but assuming that function end4Statics has already been called once (which is always the case) when a Set has been created.
So, to summarize: when initializing static members, use constEndSafe4Statics() rather than cendSafe(). In all the other cases, use simply the usual method cendSafe ().
Definition at line 295 of file set_tpl.h.
INLINE bool gum::Set< Key, Alloc >::contains | ( | const Key & | k | ) | const |
Indicates whether a given elements belong to the set.
Definition at line 578 of file set_tpl.h.
Referenced by gum::NodeGraphPart::__addHole(), gum::StaticTriangulation::__computeMaxPrimeJunctionTree(), gum::DAG::__hasDirectedPath(), gum::prm::SVED< GUM_SCALAR >::__initElimOrder(), gum::prm::SVE< GUM_SCALAR >::__initElimOrder(), gum::IBayesNet< double >::__minimalCondSetVisitDn(), gum::IBayesNet< double >::__minimalCondSetVisitUp(), gum::Potential< GUM_SCALAR >::_complementVars(), gum::MarginalTargetedInference< GUM_SCALAR >::addAllTargets(), gum::MarginalTargetedInference< GUM_SCALAR >::addTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::eraseTarget(), gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact(), gum::ArcGraphPart::existsArc(), gum::EdgeGraphPart::existsEdge(), gum::Potential< GUM_SCALAR >::fillWith(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::Set< gum::Potential< GUM_SCALAR > * >::isSubsetOf(), gum::MarginalTargetedInference< GUM_SCALAR >::isTarget(), gum::IBayesNet< double >::minimalCondSet(), gum::O3prmBNReader< GUM_SCALAR >::proceed(), gum::Estimator< GUM_SCALAR >::setFromBN(), and gum::Estimator< GUM_SCALAR >::setFromLBP().
void gum::Set< Key, Alloc >::emplace | ( | Args &&... | args | ) |
Emplace a new element in the set.
Emplace is a method that allows to construct directly an element of type Key by passing to its constructor all the arguments it needs.
args | the arguments passed to the constructor |
INLINE void gum::Set< Key, Alloc >::emplace | ( | Args &&... | args | ) |
Definition at line 647 of file set_tpl.h.
|
noexcept |
Indicates whether the set is the empty set.
Definition at line 704 of file set_tpl.h.
Referenced by gum::NodeGraphPart::__addHole(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesDownward(), gum::VariableSelector::__removeVar(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_msgL(), gum::learning::Miic::_orientation_miic(), gum::learning::Miic::_propagatesHead(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_refreshLMsPIs(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_updateNode(), gum::credal::CredalNet< GUM_SCALAR >::approximatedBinarization(), gum::DefaultPartialOrderedEliminationSequenceStrategy::eliminationUpdate(), gum::Set< gum::Potential< GUM_SCALAR > * >::empty(), gum::ArcGraphPart::emptyArcs(), gum::EdgeGraphPart::emptyEdges(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::learning::Miic::learnStructure(), gum::DefaultPartialOrderedEliminationSequenceStrategy::nextNodeToEliminate(), gum::PartialOrderedEliminationSequenceStrategy::setPartialOrder(), and gum::prm::PRMFactory< GUM_SCALAR >::startClass().
|
noexcept |
The usual unsafe end iterator to parse the set.
Definition at line 527 of file set_tpl.h.
Referenced by gum::StaticTriangulation::__computeMaxPrimeMergings(), and gum::StaticTriangulation::__triangulate().
|
static |
Returns the end iterator for other classes' statics (read the detailed description of this method).
To reduce the Sets memory consumption (which are heavily used in aGrUM) while allowing fast for(iter=begin(); iter!=end();++iter) loops, end iterators are created just once as a static member of a non-template Set. While this scheme is efficient and it works quite effectively when manipulating sets, it has a drawback: other classes with static members using the Set's end() iterator may fail to work due to the well known "static initialization order fiasco" (see Marshall Cline's C++ FAQ for more details about this C++ feature). OK, so what is the problem? Consider a class, say X, containing a Set that stores all its elements in a convenient way. To reduce memory consumption, X::end iterator is a static member that is initialized with a Set::end iterator. If the compiler decides to initialize X::end before initializing Set::end, then X::end will be in an incoherent state. Unfortunately, we cannot know for sure in which order static members will be initialized (the order is a compiler's decision). Hence, we shall enfore the fact that Set::end is initialized before X::end. Using method Set::end4Statics will ensure this fact: it uses the C++ "construct on first use" idiom (see the C++ FAQ) that ensures that the order fiasco is avoided. More precisely, end4Statics uses a global variable that is the very end iterator used by all Sets. Now, this induces a small overhead. So, we also provide a Set::end() method that returns the Set::end iterator without this small overhead, but assuming that function end4Statics has already been called once (which is always the case) when a Set has been created.
So, to summarize: when initializing static members, use end4Statics() rather than end(). In all the other cases, use simply the usual method end().
Definition at line 302 of file set_tpl.h.
|
noexcept |
The usual safe end iterator to parse the set.
Definition at line 499 of file set_tpl.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::__updateNodeSet(), gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::LeafAggregator::addLeaf(), gum::BarrenNodesFinder::barrenNodes(), gum::ArcGraphPart::eraseChildren(), gum::ArcGraphPart::eraseParents(), gum::LeafAggregator::removeLeaf(), gum::VariableSelector::select(), gum::ArcGraphPart::unvirtualizedEraseChildren(), gum::ArcGraphPart::unvirtualizedEraseParents(), gum::IMDDI< AttributeSelection, isScalar >::updateGraph(), and gum::LeafAggregator::updateLeaf().
|
static |
Returns the end iterator for other classes' statics (read the detailed description of this method).
To reduce the Sets memory consumption (which are heavily used in aGrUM) while allowing fast for(iter=begin(); iter!=end();++iter) loops, end iterators are created just once as a static member of a non-template Set. While this scheme is efficient and it works quite effectively when manipulating sets, it has a drawback: other classes with static members using the Set's end() iterator may fail to work due to the well known "static initialization order fiasco" (see Marshall Cline's C++ FAQ for more details about this C++ feature). OK, so what is the problem? Consider a class, say X, containing a Set that stores all its elements in a convenient way. To reduce memory consumption, X::end iterator is a static member that is initialized with a Set::end iterator. If the compiler decides to initialize X::end before initializing Set::end, then X::end will be in an incoherent state. Unfortunately, we cannot know for sure in which order static members will be initialized (the order is a compiler's decision). Hence, we shall enfore the fact that Set::end is initialized before X::end. Using method Set::end4Statics will ensure this fact: it uses the C++ "construct on first use" idiom (see the C++ FAQ) that ensures that the order fiasco is avoided. More precisely, end4Statics uses a global variable that is the very end iterator used by all Sets. Now, this induces a small overhead. So, we also provide a Set::end() method that returns the Set::end iterator without this small overhead, but assuming that function end4Statics has already been called once (which is always the case) when a Set has been created.
So, to summarize: when initializing static members, use endSafe4Statics() rather than endSafe (). In all the other cases, use simply the usual method endSafe ().
Definition at line 288 of file set_tpl.h.
INLINE void gum::Set< Key, Alloc >::erase | ( | const Key & | k | ) |
Erases an element from the set.
k | The element to remove. |
Definition at line 653 of file set_tpl.h.
Referenced by gum::NodeGraphPart::__addHole(), gum::prm::StructuredInference< GUM_SCALAR >::__buildPatternGraph(), gum::prm::StructuredInference< GUM_SCALAR >::__buildReduceGraph(), gum::StaticTriangulation::__computeRecursiveThinning(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), gum::prm::StructuredInference< GUM_SCALAR >::__removeNode(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_msgP(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_refreshLMsPIs(), gum::BarrenNodesFinder::barrenNodes(), gum::prm::StructuredInference< GUM_SCALAR >::CData::CData(), gum::BayesNetInference< GUM_SCALAR >::chgEvidence(), gum::DefaultPartialOrderedEliminationSequenceStrategy::eliminationUpdate(), gum::Set< gum::Potential< GUM_SCALAR > * >::erase(), gum::ArcGraphPart::eraseArc(), gum::EdgeGraphPart::eraseEdge(), gum::BayesNetInference< GUM_SCALAR >::eraseEvidence(), gum::MarginalTargetedInference< GUM_SCALAR >::eraseTarget(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), and gum::ITI< AttributeSelection, isScalar >::updateGraph().
INLINE void gum::Set< Key, Alloc >::erase | ( | const iterator_safe & | k | ) |
Erases an element from the set.
k | The iterator pointing to the element to remove. |
Definition at line 665 of file set_tpl.h.
INLINE bool gum::Set< Key, Alloc >::exists | ( | const Key & | k | ) | const |
Indicates whether a given elements belong to the set.
Definition at line 604 of file set_tpl.h.
Referenced by gum::prm::StructuredBayesBall< GUM_SCALAR >::__buildHashKey(), gum::prm::StructuredInference< GUM_SCALAR >::__buildPatternGraph(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__directedPath(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), gum::prm::StructuredInference< GUM_SCALAR >::__insertNodeInElimLists(), gum::prm::StructuredInference< GUM_SCALAR >::__removeBarrenNodes(), gum::prm::StructuredInference< GUM_SCALAR >::__removeNode(), gum::DAGCycleDetector::__restrictWeightedSet(), gum::prm::SVE< GUM_SCALAR >::__variableElimination(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_updateNode(), gum::BarrenNodesFinder::barrenNodes(), gum::Set< gum::Potential< GUM_SCALAR > * >::contains(), gum::Set< gum::Potential< GUM_SCALAR > * >::exists(), gum::BayesNetInference< GUM_SCALAR >::hasHardEvidence(), gum::MarkovBlanket::hasSameStructure(), gum::DAGmodel::hasSameStructure(), gum::BayesNetInference< GUM_SCALAR >::hasSoftEvidence(), gum::StructuredPlaner< double >::optimalPolicy2String(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), and gum::MarkovBlanket::toDot().
HashTable< Key, NewKey, NewAlloc > gum::Set< Key, Alloc >::hashMap | ( | NewKey(*)(const Key &) | f, |
Size | capacity = 0 |
||
) | const |
Creates a hashtable of NewKey from the set.
f | A function that maps Key into a NewKey |
capacity | The size of the resulting hashtable. When equal to 0, a default size is computed that is a good trade-off between space consumption and efficiency of new elements insertions. |
Definition at line 835 of file set_tpl.h.
HashTable< Key, NewKey, NewAlloc > gum::Set< Key, Alloc >::hashMap | ( | const NewKey & | val, |
Size | size = 0 |
||
) | const |
Creates a hash table of NewKey from the set.
val | The value taken by all the elements of the resulting hashtable. |
size | The size of the resulting hash table. When equal to 0, a default size is computed that is a good trade-off between space consumption and efficiency of new elements insertions. |
Definition at line 857 of file set_tpl.h.
INLINE void gum::Set< Key, Alloc >::insert | ( | const Key & | k | ) |
Inserts a new element into the set.
k | The new element to insert. |
Definition at line 610 of file set_tpl.h.
Referenced by gum::prm::StructuredInference< GUM_SCALAR >::__addEdgesInReducedGraph(), gum::NodeGraphPart::__addHole(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__AR(), gum::MarkovBlanket::__buildMarkovBlanket(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__buildPatternGraph(), gum::prm::StructuredInference< GUM_SCALAR >::__buildPatternGraph(), gum::prm::StructuredInference< GUM_SCALAR >::__buildReduceGraph(), gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::__checkO3IntTypes(), gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::__checkO3RealTypes(), gum::StaticTriangulation::__computeRecursiveThinning(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__connect(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::__directedPath(), gum::prm::SVE< GUM_SCALAR >::__eliminateDelayedVariables(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesDownward(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesDownward(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesUpward(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__elimination_cost(), gum::prm::StructuredBayesBall< GUM_SCALAR >::__fillMaps(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::__generateClasses(), gum::prm::LayerGenerator< GUM_SCALAR >::__generateClasses(), gum::DAG::__hasDirectedPath(), gum::prm::SVED< GUM_SCALAR >::__initElimOrder(), gum::prm::SVE< GUM_SCALAR >::__initElimOrder(), gum::prm::gspan::DFSTree< GUM_SCALAR >::__initialiaze_root(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVED< GUM_SCALAR >::__initReqSets(), gum::prm::SVED< GUM_SCALAR >::__insertEvidence(), gum::prm::SVE< GUM_SCALAR >::__insertEvidence(), gum::prm::SVED< GUM_SCALAR >::__insertLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__insertLiftedNodes(), gum::prm::StructuredInference< GUM_SCALAR >::__insertNodeInElimLists(), gum::prm::PRMInstance< GUM_SCALAR >::__instantiateSlotChain(), gum::OrderedEliminationSequenceStrategy::__isOrderNeeded(), gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), gum::prm::StructuredInference< GUM_SCALAR >::__reducePattern(), gum::prm::StructuredInference< GUM_SCALAR >::__removeBarrenNodes(), gum::prm::GSpan< GUM_SCALAR >::__sortPatterns(), gum::EssentialGraph::__strongly_protected(), gum::StaticTriangulation::__triangulate(), gum::prm::SVE< GUM_SCALAR >::__variableElimination(), gum::Potential< GUM_SCALAR >::_complementVars(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_initialize(), gum::PartialOrderedEliminationSequenceStrategy::_isPartialOrderNeeded(), gum::prm::SVED< GUM_SCALAR >::_marginal(), gum::prm::SVE< GUM_SCALAR >::_marginal(), gum::prm::StructuredInference< GUM_SCALAR >::_marginal(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_msgL(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_transpose(), gum::MarginalTargetedInference< GUM_SCALAR >::addAllTargets(), gum::ArcGraphPart::addArc(), gum::EdgeGraphPart::addEdge(), gum::BayesNetInference< GUM_SCALAR >::addEvidence(), gum::LeafAggregator::addLeaf(), gum::NodeGraphPart::addNodeWithId(), gum::MarginalTargetedInference< GUM_SCALAR >::addTarget(), gum::NodeGraphPart::asNodeSet(), gum::BarrenNodesFinder::barrenNodes(), gum::BarrenNodesFinder::barrenPotentials(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::buildClasses(), gum::prm::StructuredInference< GUM_SCALAR >::CData::CData(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetInference< GUM_SCALAR >::chgEvidence(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::completeAttributes(), gum::prm::eliminateNode(), gum::DefaultPartialOrderedEliminationSequenceStrategy::eliminationUpdate(), gum::MarginalTargetedInference< GUM_SCALAR >::evidenceImpact(), gum::JointTargetedInference< GUM_SCALAR >::evidenceJointImpact(), gum::StaticTriangulation::fillIns(), gum::Potential< GUM_SCALAR >::fillWith(), gum::Potential< GUM_SCALAR >::findAll(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::prm::gspan::DFSTree< GUM_SCALAR >::growPattern(), gum::DAGCycleDetector::hasCycleFromModifications(), gum::FMDPLearner< VariableAttributeSelection, RewardAttributeSelection, LearnerSelection >::initialize(), gum::Set< gum::Potential< GUM_SCALAR > * >::insert(), gum::JointTargetedInference< GUM_SCALAR >::jointMutualInformation(), gum::Set< gum::Potential< GUM_SCALAR > * >::operator+=(), gum::prm::PRMClass< double >::PRMClass(), gum::O3prmBNReader< GUM_SCALAR >::proceed(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveClassElement(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveInterface(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveSlotType(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveType(), gum::BayesNet< double >::reverseArc(), gum::PartialOrderedEliminationSequenceStrategy::setPartialOrder(), gum::prm::PRMFactory< GUM_SCALAR >::startClass(), gum::IMDDI< AttributeSelection, isScalar >::updateGraph(), and gum::ITI< AttributeSelection, isScalar >::updateGraph().
INLINE void gum::Set< Key, Alloc >::insert | ( | Key && | k | ) |
Inserts a new element into the set.
k | The new element to insert. |
Definition at line 628 of file set_tpl.h.
bool gum::Set< Key, Alloc >::isSubsetOf | ( | const Set< Key, OtherAlloc > & | s | ) | const |
Referenced by gum::Set< gum::Potential< GUM_SCALAR > * >::isSupersetOf(), and gum::JointTargetedInference< GUM_SCALAR >::jointPosterior().
INLINE bool gum::Set< Key, Alloc >::isSubsetOf | ( | const Set< Key, OtherAlloc > & | s | ) | const |
Definition at line 586 of file set_tpl.h.
bool gum::Set< Key, Alloc >::isSupersetOf | ( | const Set< Key, OtherAlloc > & | s | ) | const |
List< NewKey, NewAlloc > gum::Set< Key, Alloc >::listMap | ( | NewKey(*)(const Key &) | f | ) | const |
A method to create a List of NewKey from the set.
f | A function that maps a Key into a NewKey |
Definition at line 881 of file set_tpl.h.
INLINE bool gum::Set< Key, Alloc >::operator!= | ( | const Set< Key, OtherAlloc > & | s2 | ) | const |
Definition at line 478 of file set_tpl.h.
Set< Key, Alloc > gum::Set< Key, Alloc >::operator* | ( | const Set< Key, OtherAlloc > & | s2 | ) | const |
Intersection operator.
OtherAlloc | The other gum::Set allocator. |
s2 | The gum::Set to intersect. |
Definition at line 712 of file set_tpl.h.
const Set< Key, Alloc > & gum::Set< Key, Alloc >::operator*= | ( | const Set< Key, OtherAlloc > & | s2 | ) |
Intersection update operator.
OtherAlloc | The other gum::Set allocator. |
s2 | The gum::Set to intersect. |
Definition at line 739 of file set_tpl.h.
Set< Key, Alloc > gum::Set< Key, Alloc >::operator+ | ( | const Set< Key, OtherAlloc > & | s2 | ) | const |
Union operator.
OtherAlloc | The other gum::Set allocator. |
s2 | The gum::Set to union. |
Definition at line 770 of file set_tpl.h.
const Set< Key, Alloc > & gum::Set< Key, Alloc >::operator+= | ( | const Set< Key, OtherAlloc > & | s2 | ) |
Union update operator.
OtherAlloc | The other gum::Set allocator. |
s2 | The gum::Set to update |
Definition at line 755 of file set_tpl.h.
Set< Key, Alloc > gum::Set< Key, Alloc >::operator- | ( | const Set< Key, OtherAlloc > & | s2 | ) | const |
Disjunction operator.
OtherAlloc | The other gum::Set allocator. |
s2 | The gum::Set to disjunct. |
Definition at line 788 of file set_tpl.h.
INLINE Set< Key, Alloc > & gum::Set< Key, Alloc >::operator<< | ( | const Key & | k | ) |
Adds a new element to the set (alias for insert).
k | The new element to add. |
Definition at line 677 of file set_tpl.h.
INLINE Set< Key, Alloc > & gum::Set< Key, Alloc >::operator<< | ( | Key && | k | ) |
Adds a new element to the set (alias for insert).
k | The new element to add. |
Definition at line 684 of file set_tpl.h.
Set< Key, Alloc > & gum::Set< Key, Alloc >::operator= | ( | const Set< Key, Alloc > & | from | ) |
Copy operator.
from | The gum::Set to copy. |
Definition at line 388 of file set_tpl.h.
Set< Key, Alloc > & gum::Set< Key, Alloc >::operator= | ( | const Set< Key, OtherAlloc > & | from | ) |
Generalized copy operator.
from | The gum::Set to copy. |
OtherAlloc | The other gum::Set allocator. |
Definition at line 420 of file set_tpl.h.
Set< Key, Alloc > & gum::Set< Key, Alloc >::operator= | ( | Set< Key, Alloc > && | from | ) |
bool gum::Set< Key, Alloc >::operator== | ( | const Set< Key, OtherAlloc > & | s2 | ) | const |
Mathematical equality between two sets.
s2 | The gum::Set to test for equality. |
OtherAlloc | The other gum::Set allocator. |
Definition at line 458 of file set_tpl.h.
INLINE Set< Key, Alloc > & gum::Set< Key, Alloc >::operator>> | ( | const Key & | k | ) |
INLINE void gum::Set< Key, Alloc >::resize | ( | Size | new_capacity | ) |
Changes the size of the underlying hash table containing the set.
See gum::HashTable::resize(Size) method resize for more details.
new_capacity | The underlying hash table new size. |
Definition at line 549 of file set_tpl.h.
Referenced by gum::StaticTriangulation::__triangulate(), and gum::Set< gum::Potential< GUM_SCALAR > * >::resize().
Returns the current resizing policy of the underlying hash table.
Definition at line 572 of file set_tpl.h.
Referenced by gum::Set< gum::Potential< GUM_SCALAR > * >::operator=(), and gum::Set< gum::Potential< GUM_SCALAR > * >::resizePolicy().
INLINE void gum::Set< Key, Alloc >::setResizePolicy | ( | const bool | new_policy | ) |
Enables the user to change dynamically the resizing policy of the underlying hash table.
When new_policy is false, the set will not try to change its memory size, hence resulting in potentially slower accesses.
new_policy | If true the set updates dynamically its memory consumption to guarantee that its elements are fast to retrieve. |
Definition at line 561 of file set_tpl.h.
Referenced by gum::Set< gum::Potential< GUM_SCALAR > * >::setResizePolicy().
|
noexcept |
Returns the number of elements in the set.
Definition at line 698 of file set_tpl.h.
Referenced by gum::prm::StructuredInference< GUM_SCALAR >::__buildReduceGraph(), gum::DefaultJunctionTreeStrategy::__computeJunctionTree(), gum::BinaryJoinTreeConverterDefault::__convertClique(), gum::prm::StructuredInference< GUM_SCALAR >::__eliminateObservedNodes(), gum::prm::StructuredInference< GUM_SCALAR >::__eliminateObservedNodesInSource(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::__elimination_cost(), gum::prm::LayerGenerator< GUM_SCALAR >::__generateClassDag(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::__generateClassDag(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), gum::prm::StructuredInference< GUM_SCALAR >::__insertNodeInElimLists(), gum::prm::StructuredInference< GUM_SCALAR >::__reduceAloneInstances(), gum::EssentialGraph::__strongly_protected(), gum::StaticTriangulation::__triangulate(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_initialize(), gum::learning::Miic::_initiation(), gum::prm::StructuredInference< GUM_SCALAR >::_marginal(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_msgL(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::_msgP(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::_updateNode(), gum::BarrenNodesFinder::barrenNodes(), gum::prm::StructuredInference< GUM_SCALAR >::CData::CData(), gum::prm::eliminateNode(), gum::StaticTriangulation::fillIns(), gum::prm::gspan::DFSTree< GUM_SCALAR >::frequency(), gum::Set< gum::Potential< GUM_SCALAR > * >::isSubsetOf(), gum::JointTargetedInference< GUM_SCALAR >::jointMutualInformation(), gum::BayesNetInference< GUM_SCALAR >::nbrHardEvidence(), gum::BayesNetInference< GUM_SCALAR >::nbrSoftEvidence(), gum::MarginalTargetedInference< GUM_SCALAR >::nbrTargets(), gum::prm::gspan::DFSTree< GUM_SCALAR >::NeighborDegreeSort::operator()(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveClassElement(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveInterface(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveSlotType(), gum::prm::o3prm::O3NameSolver< GUM_SCALAR >::resolveType(), gum::Set< gum::Potential< GUM_SCALAR > * >::size(), gum::ArcGraphPart::sizeArcs(), gum::EdgeGraphPart::sizeEdges(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), and gum::StaticTriangulation::triangulatedGraph().
INLINE std::string gum::Set< Key, Alloc >::toString | ( | ) | const |
Prints the content of the set.
Definition at line 803 of file set_tpl.h.
|
friend |
|
friend |
|
friend |
|
private |
A set of X's is actually a hash table whose keys are the X's.
Definition at line 764 of file set.h.
Referenced by gum::Set< gum::Potential< GUM_SCALAR > * >::operator*(), gum::Set< gum::Potential< GUM_SCALAR > * >::operator*=(), gum::Set< gum::Potential< GUM_SCALAR > * >::operator+(), gum::Set< gum::Potential< GUM_SCALAR > * >::operator+=(), gum::Set< gum::Potential< GUM_SCALAR > * >::operator-(), gum::Set< gum::Potential< GUM_SCALAR > * >::operator=(), and gum::Set< gum::Potential< GUM_SCALAR > * >::operator==().