36 template <
typename Key >
42 template <
typename Key >
43 template <
typename Alloc >
47 :
set.__inside.cbeginSafe()} {
52 template <
typename Key >
60 template <
typename Key >
67 template <
typename Key >
69 __ht_iter{std::move(from.__ht_iter)} {
74 template <
typename Key >
80 template <
typename Key >
88 template <
typename Key >
96 template <
typename Key >
99 __ht_iter = std::move(from.__ht_iter);
104 template <
typename Key >
114 template <
typename Key >
122 template <
typename Key >
128 template <
typename Key >
131 return __ht_iter != from.__ht_iter;
136 template <
typename Key >
139 return __ht_iter == from.__ht_iter;
143 template <
typename Key >
147 return __ht_iter.key();
151 template <
typename Key >
155 return &(__ht_iter.key());
160 template <
typename Key >
170 template <
typename Key >
176 template <
typename Key >
177 template <
typename Alloc >
181 :
set.__inside.cbegin()} {
186 template <
typename Key >
193 template <
typename Key >
200 template <
typename Key >
206 template <
typename Key >
214 template <
typename Key >
222 template <
typename Key >
232 template <
typename Key >
239 template <
typename Key >
245 template <
typename Key >
253 template <
typename Key >
260 template <
typename Key >
268 template <
typename Key >
277 template <
typename Key >
287 template <
typename Key,
typename Alloc >
290 SetIteratorStaticEnd::endSafe4Statics()));
294 template <
typename Key,
typename Alloc >
297 SetIteratorStaticEnd::constEndSafe4Statics()));
301 template <
typename Key,
typename Alloc >
304 SetIteratorStaticEnd::end4Statics()));
308 template <
typename Key,
typename Alloc >
311 SetIteratorStaticEnd::constEnd4Statics()));
315 template <
typename Key,
typename Alloc >
320 __inside(capacity, resize_policy, false) {
321 GUM_CONSTRUCTOR(
Set);
329 template <
typename Key,
typename Alloc >
331 __inside(
Size(list.size()) / 2, true, false) {
332 GUM_CONSTRUCTOR(
Set);
333 for (
const auto& elt : list) {
343 template <
typename Key,
typename Alloc >
345 __inside(s.__inside) {
350 template <
typename Key,
typename Alloc >
351 template <
typename OtherAlloc >
353 __inside(s.__inside) {
358 template <
typename Key,
typename Alloc >
360 __inside(
std::move(s.__inside)) {
365 template <
typename Key,
typename Alloc >
371 template <
typename Key,
typename Alloc >
387 template <
typename Key,
typename Alloc >
417 template <
typename Key,
typename Alloc >
418 template <
typename OtherAlloc >
449 template <
typename Key,
typename Alloc >
451 __inside = std::move(from.__inside);
456 template <
typename Key,
typename Alloc >
457 template <
typename OtherAlloc >
462 if (size() != h2.
size())
return false;
466 iter != __inside.cend();
468 if (!h2.
exists(iter.key()))
return false;
475 template <
typename Key,
typename Alloc >
476 template <
typename OtherAlloc >
483 template <
typename Key,
typename Alloc >
490 template <
typename Key,
typename Alloc >
497 template <
typename Key,
typename Alloc >
501 SetIteratorStaticEnd::__SetIterEndSafe));
505 template <
typename Key,
typename Alloc >
509 SetIteratorStaticEnd::__SetIterEndSafe));
513 template <
typename Key,
typename Alloc >
519 template <
typename Key,
typename Alloc >
526 template <
typename Key,
typename Alloc >
530 SetIteratorStaticEnd::__SetIterEnd));
534 template <
typename Key,
typename Alloc >
538 SetIteratorStaticEnd::__SetIterEnd));
542 template <
typename Key,
typename Alloc >
548 template <
typename Key,
typename Alloc >
550 __inside.
resize(new_size);
560 template <
typename Key,
typename Alloc >
571 template <
typename Key,
typename Alloc >
577 template <
typename Key,
typename Alloc >
579 return __inside.
exists(k);
583 template <
typename Key,
typename Alloc >
584 template <
typename OtherAlloc >
587 if (this->size() >= s.
size()) {
return false; }
589 for (
const auto& elt : *
this) {
590 if (!s.
contains(elt)) {
return false; }
595 template <
typename Key,
typename Alloc >
596 template <
typename OtherAlloc >
603 template <
typename Key,
typename Alloc >
605 return __inside.
exists(k);
609 template <
typename Key,
typename Alloc >
627 template <
typename Key,
typename Alloc >
634 __inside.
insert(std::move(k),
true);
645 template <
typename Key,
typename Alloc >
646 template <
typename... Args >
648 insert(std::move(Key(std::forward< Args >(args)...)));
652 template <
typename Key,
typename Alloc >
664 template <
typename Key,
typename Alloc >
676 template <
typename Key,
typename Alloc >
683 template <
typename Key,
typename Alloc >
685 insert(std::move(k));
690 template <
typename Key,
typename Alloc >
697 template <
typename Key,
typename Alloc >
699 return __inside.
size();
703 template <
typename Key,
typename Alloc >
705 return __inside.
empty();
709 template <
typename Key,
typename Alloc >
710 template <
typename OtherAlloc >
717 if (size() < h2.
size()) {
719 iter != __inside.cend();
721 if (h2.
exists(iter.key())) h_r.
insert(iter.key(),
true);
727 if (__inside.exists(iter.key())) h_r.
insert(iter.key(),
true);
736 template <
typename Key,
typename Alloc >
737 template <
typename OtherAlloc >
742 for (
auto iter = __inside.beginSafe(); iter != __inside.endSafe(); ++iter) {
743 if (!h2.
exists(iter.key())) __inside.erase(iter);
752 template <
typename Key,
typename Alloc >
753 template <
typename OtherAlloc >
758 if (!__inside.exists(pair.first)) __inside.
insert(pair.first,
true);
767 template <
typename Key,
typename Alloc >
768 template <
typename OtherAlloc >
777 if (!h_r.
exists(iter.key())) h_r.
insert(iter.key(),
true);
785 template <
typename Key,
typename Alloc >
786 template <
typename OtherAlloc >
794 iter != __inside.cend();
796 if (!h2.
exists(iter.key())) h_r.
insert(iter.key(),
true);
802 template <
typename Key,
typename Alloc >
804 std::stringstream out;
808 for (
iterator iter = begin(); iter != end(); ++iter) {
825 template <
typename Key,
typename Alloc >
826 std::ostream& operator<<(std::ostream& stream, const Set< Key, Alloc >&
set) {
827 stream <<
set.toString();
832 template <
typename Key,
typename Alloc >
833 template <
typename NewKey,
typename NewAlloc >
839 if (size == 0) size = std::max(
Size(2), __inside.size() / 2);
846 iter != __inside.cend();
848 table.insert(iter.key(), f(iter.key()));
855 template <
typename Key,
typename Alloc >
856 template <
typename NewKey,
typename NewAlloc >
862 if (size == 0) size = std::max(
Size(2), __inside.size() / 2);
869 iter != __inside.cend();
871 table.insert(iter.key(), val);
878 template <
typename Key,
typename Alloc >
879 template <
typename NewKey,
typename NewAlloc >
887 iter != __inside.cend();
897 template <
typename T,
typename Alloc >
901 for (
const auto& k : key) {
910 template <
typename T,
typename Alloc >
913 return (castToSize(key) * HashFuncConst::gold) & this->_hash_mask;
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
const key_type & key() const
Returns the key corresponding to the element pointed to by the iterator.
bool empty() const noexcept
Indicates whether the set is the empty set.
SetIterator< Key > operator+(Size i) const noexcept
Returns a new iterator.
static const const_iterator_safe & constEndSafe4Statics()
Returns the end iterator for other classes' statics (read the detailed description of this method)...
bool operator!=(const SetIterator< Key > &from) const noexcept
Indicates whether two iterators point to different elements or sets.
Safe iterators for the Set classDevelopers may consider using Set<x>::iterator_safe instead of SetIte...
Size capacity() const
Returns the capacity of the underlying hash table containing the set.
Size size() const noexcept
Returns the number of elements stored into the hashtable.
bool isSubsetOf(const Set< Key, OtherAlloc > &s) const
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
Class template representing hashing function of LpCol.
void erase(const Key &k)
Erases an element from the set.
void clear() noexcept
Makes the iterator point toward nothing (in particular, it is not related anymore to its current hash...
Generic doubly linked lists.
gum is the global namespace for all aGrUM entities
bool operator==(const SetIterator< Key > &from) const noexcept
Indicates whether two iterators point toward the same element of a same set.
The class for generic Hash Tables.
SetIterator() noexcept
Default constructor: the iterator points toward nothing.
std::istream & operator>>(std::istream &in, TiXmlNode &base)
Representation of a setA Set is a structure that contains arbitrary elements.
static const iterator & end4Statics()
Returns the end iterator for other classes' statics (read the detailed description of this method)...
HashTableConstIteratorSafe< Key, bool > __ht_iter
The underlying iterator for the set's hash table containing the data.
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
Position
An enumeration to position the iterator at the beginning or the end of the set.
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map's DAG in output using the Graphviz-dot format.
void resize(Size new_capacity)
Changes the size of the underlying hash table containing the set.
HashTableConstIterator< Key, bool > __ht_iter
The underlying iterator for the set's hash table containing the data.
bool resizePolicy() const
Returns the current resizing policy of the underlying hash table.
Position
An enumeration to position the iterator at the beginning or the end of the set.
const const_iterator & cend() const noexcept
Returns the unsafe const_iterator pointing to the end of the hashtable.
LpExpr operator+(LpExpr &&lhs, const T2 &rhs)
Overload of operator + between anything ( a scalar, a variable or an expression ) and anything except...
Val & pushBack(const Val &val)
Inserts a new element (a copy) at the end of the chained list.
bool operator==(const TiXmlString &a, const TiXmlString &b)
void setResizePolicy(const bool new_policy)
Enables the user to change dynamically the resizing policy of the underlying hash table...
static const iterator_safe & endSafe4Statics()
Returns the end iterator for other classes' statics (read the detailed description of this method)...
SetIterator< Key > & operator+=(Size i) noexcept
Makes the iterator point to i elements further in the set.
void clear() noexcept
makes the iterator point toward nothing (in particular, it is not related anymore to its current set)...
friend class Set
Friends to speed up access.
const_iterator cbegin() const
Returns an unsafe const_iterator pointing to the beginning of the hashtable.
const Key * operator->() const
Returns a pointer to the element pointed to by the iterator.
Unsafe iterators for the Set class.
LpExpr operator*(const SCALAR &lhs, const LpCol &rhs)
Overload of operator * between a scalar and a variable.
SetIterator< Key > & operator++() noexcept
Increments the iterator.
bool operator!=(const TiXmlString &a, const TiXmlString &b)
void clear() noexcept
makes the iterator point toward nothing (in particular, it is not related anymore to its current set)...
HashTable< Key, bool, Alloc > __inside
A set of X's is actually a hash table whose keys are the X's.
~SetIterator() noexcept
Class destructor.
void clear()
Removes all the elements, if any, from the set.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
LpExpr operator-(LpExpr &&lhs, const T2 &rhs)
Overload of operator - between anything ( a scalar, a variable or an expression ) and anything except...
Size size() const noexcept
Returns the number of elements in the set.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
SetIteratorSafe()
Default constructor: the iterator points toward nothing.
static const const_iterator & constEnd4Statics()
Returns the end iterator for other classes' statics (read the detailed description of this method)...
void insert(const Key &k)
Inserts a new element into the set.
const Key & operator*() const
Returns the element pointed to by the iterator.
SetIterator< Key > & operator=(const SetIterator< Key > &from) noexcept
Assignment operator.