51#ifndef DOXYGEN_SHOULD_SKIP_THIS
65 const std::size_t
size = _ids_.size();
66 for (std::size_t i = _nb_lhs_ids_; i <
size; ++i)
67 set._ids_ << _ids_[i];
68 set._end_safe_._gotoEnd_();
75 const std::size_t
size = _ids_.size();
76 std::size_t
pos = std::size_t(0);
78 if (_ids_[
pos] ==
id)
break;
83 _ids_.erase(SequenceIteratorSafe< NodeId >(_ids_,
pos));
84 if (
pos < _nb_lhs_ids_) --_nb_lhs_ids_;
85 _end_safe_._gotoEnd_();
91 std::string str =
"{";
94 for (std::size_t i = std::size_t(0); i < _nb_lhs_ids_; ++i) {
95 if (deja) str +=
" , ";
97 str += std::format(
"{}", _ids_[i]);
101 for (
auto iter = _ids_.begin() + _nb_lhs_ids_; iter != _ids_.end(); ++iter) {
102 if (deja) str +=
" , ";
107 str += std::format(
"{}", *iter);
119 for (
auto i = std::size_t(0); i < _ids_.size(); ++i)
120 if (i < _nb_lhs_ids_) left.
insert(_ids_[i]);
121 else right.
insert(_ids_[i]);
122 return {left, right};
127 if (set._ids_.size() > _ids_.size())
return false;
128 for (
const auto node: set._ids_) {
129 if (!_ids_.exists(node))
return false;
136 return stream << idset.toString();
141 const bool ordered_ids) : _end_safe_(*this) {
142 _ids_.resize(ids.size());
147 std::vector< NodeId > vect(ids);
148 std::sort(vect.begin(), vect.end());
149 for (
const auto id: vect)
152 for (
const auto id: ids)
156 if (!rhs_ids) _nb_lhs_ids_ = _ids_.size();
159 _end_safe_._gotoEnd_();
161 GUM_CONSTRUCTOR(IdCondSet);
164 IdCondSet::IdCondSet(NodeId var1,
166 const std::vector< NodeId >& rhs_ids,
167 const bool ordered_lhs_vars,
168 const bool ordered_rhs_ids) :
169 _nb_lhs_ids_(
std::size_t(2)), _end_safe_(*this) {
170 _ids_.resize(rhs_ids.size() + std::size_t(2));
174 if (!ordered_lhs_vars && (var1 > var2)) std::swap(var1, var2);
180 if (!ordered_rhs_ids) {
181 std::vector< NodeId > vect(rhs_ids);
182 std::sort(vect.begin(), vect.end());
183 for (
const auto id: vect)
186 for (
const auto id: rhs_ids)
191 _end_safe_._gotoEnd_();
193 GUM_CONSTRUCTOR(IdCondSet);
196 IdCondSet::IdCondSet(NodeId var1,
199 const std::vector< NodeId >& rhs_ids,
200 const bool ordered_lhs_vars,
201 const bool ordered_rhs_ids) :
202 _nb_lhs_ids_(
std::size_t(3)), _end_safe_(*this) {
203 _ids_.resize(rhs_ids.size() + std::size_t(3));
207 if (!ordered_lhs_vars) {
208 if (var1 > var2) std::swap(var1, var2);
209 if (var1 > var3) std::swap(var1, var3);
210 if (var2 > var3) std::swap(var2, var3);
218 if (!ordered_rhs_ids) {
219 std::vector< NodeId > vect(rhs_ids);
220 std::sort(vect.begin(), vect.end());
221 for (
const auto id: vect)
224 for (
const auto id: rhs_ids)
229 _end_safe_._gotoEnd_();
231 GUM_CONSTRUCTOR(IdCondSet);
236 Size HashFunc< learning::IdCondSet >::castToSize(
const learning::IdCondSet& key) {
237 Size h = Size(key.nbLHSIds());
238 const Sequence< NodeId >& vect = key.ids();
239 const std::size_t size = vect.size();
241 for (std::size_t i = std::size_t(0); i < size; ++i) {
242 h ^= Size(vect[i]) + Size(0x9e3779b9u) + (h << 6) + (h >> 2);
void insert(const Key &k)
Inserts a new element into the set.
A class for storing a pair of sets of NodeIds, the second one corresponding to a conditional set.
bool contains(const IdCondSet &set) const
indicates whether the IdCondSet contains the IdCondSet passed in argument
IdCondSet conditionalIdCondSet() const
returns the idSet at the right hand side of the conditioning bar
std::size_t pos(const NodeId id) const
returns the position of a given node in the IdCondSet
std::string toString() const
returns the content of the set as a string
std::pair< NodeSet, NodeSet > toNodeSets() const
returns the pair of conditioned gum::NodeSet and conditioning gum::NodeSet
void erase(const NodeId id)
erase a node in the idset
std::size_t size() const
returns the number of variables (both left and right hand side)
IdCondSet()
default constructor
Size NodeId
Type for node ids.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
A class used by learning caches to represent uniquely sets of variables.
Template implementation of idSets.
include the inlined functions if necessary
std::ostream & operator<<(std::ostream &stream, const IdCondSet &idset)
the display operator
gum is the global namespace for all aGrUM entities