39 template <
typename Key >
45 template <
typename Key >
46 template <
typename Alloc >
50 :
set.__inside.cbeginSafe()} {
55 template <
typename Key >
63 template <
typename Key >
70 template <
typename Key >
72 __ht_iter{std::move(from.__ht_iter)} {
77 template <
typename Key >
83 template <
typename Key >
91 template <
typename Key >
99 template <
typename Key >
102 __ht_iter = std::move(from.__ht_iter);
107 template <
typename Key >
117 template <
typename Key >
125 template <
typename Key >
131 template <
typename Key >
135 return __ht_iter != from.__ht_iter;
140 template <
typename Key >
144 return __ht_iter == from.__ht_iter;
148 template <
typename Key >
152 return __ht_iter.key();
156 template <
typename Key >
160 return &(__ht_iter.key());
165 template <
typename Key >
175 template <
typename Key >
181 template <
typename Key >
182 template <
typename Alloc >
186 :
set.__inside.cbegin()} {
191 template <
typename Key >
198 template <
typename Key >
205 template <
typename Key >
211 template <
typename Key >
219 template <
typename Key >
227 template <
typename Key >
237 template <
typename Key >
244 template <
typename Key >
250 template <
typename Key >
258 template <
typename Key >
265 template <
typename Key >
273 template <
typename Key >
282 template <
typename Key >
292 template <
typename Key,
typename Alloc >
295 SetIteratorStaticEnd::endSafe4Statics()));
299 template <
typename Key,
typename Alloc >
302 SetIteratorStaticEnd::constEndSafe4Statics()));
306 template <
typename Key,
typename Alloc >
309 SetIteratorStaticEnd::end4Statics()));
313 template <
typename Key,
typename Alloc >
316 SetIteratorStaticEnd::constEnd4Statics()));
320 template <
typename Key,
typename Alloc >
325 __inside(capacity, resize_policy, false) {
326 GUM_CONSTRUCTOR(
Set);
334 template <
typename Key,
typename Alloc >
336 __inside(
Size(list.size()) / 2, true, false) {
337 GUM_CONSTRUCTOR(
Set);
338 for (
const auto& elt: list) {
348 template <
typename Key,
typename Alloc >
350 __inside(s.__inside) {
355 template <
typename Key,
typename Alloc >
356 template <
typename OtherAlloc >
358 __inside(s.__inside) {
363 template <
typename Key,
typename Alloc >
365 __inside(
std::move(s.__inside)) {
370 template <
typename Key,
typename Alloc >
376 template <
typename Key,
typename Alloc >
392 template <
typename Key,
typename Alloc >
422 template <
typename Key,
typename Alloc >
423 template <
typename OtherAlloc >
454 template <
typename Key,
typename Alloc >
456 __inside = std::move(from.__inside);
461 template <
typename Key,
typename Alloc >
462 template <
typename OtherAlloc >
467 if (size() != h2.
size())
return false;
471 iter != __inside.cend();
473 if (!h2.
exists(iter.key()))
return false;
480 template <
typename Key,
typename Alloc >
481 template <
typename OtherAlloc >
488 template <
typename Key,
typename Alloc >
495 template <
typename Key,
typename Alloc >
502 template <
typename Key,
typename Alloc >
506 SetIteratorStaticEnd::__SetIterEndSafe));
510 template <
typename Key,
typename Alloc >
514 SetIteratorStaticEnd::__SetIterEndSafe));
518 template <
typename Key,
typename Alloc >
524 template <
typename Key,
typename Alloc >
531 template <
typename Key,
typename Alloc >
535 SetIteratorStaticEnd::__SetIterEnd));
539 template <
typename Key,
typename Alloc >
543 SetIteratorStaticEnd::__SetIterEnd));
547 template <
typename Key,
typename Alloc >
553 template <
typename Key,
typename Alloc >
555 __inside.
resize(new_size);
565 template <
typename Key,
typename Alloc >
576 template <
typename Key,
typename Alloc >
582 template <
typename Key,
typename Alloc >
584 return __inside.
exists(k);
588 template <
typename Key,
typename Alloc >
589 template <
typename OtherAlloc >
592 if (this->size() >= s.
size()) {
return false; }
594 for (
const auto& elt: *
this) {
595 if (!s.
contains(elt)) {
return false; }
600 template <
typename Key,
typename Alloc >
601 template <
typename OtherAlloc >
608 template <
typename Key,
typename Alloc >
610 return __inside.
exists(k);
614 template <
typename Key,
typename Alloc >
632 template <
typename Key,
typename Alloc >
639 __inside.
insert(std::move(k),
true);
650 template <
typename Key,
typename Alloc >
651 template <
typename... Args >
653 insert(std::move(Key(std::forward< Args >(args)...)));
657 template <
typename Key,
typename Alloc >
669 template <
typename Key,
typename Alloc >
681 template <
typename Key,
typename Alloc >
688 template <
typename Key,
typename Alloc >
690 insert(std::move(k));
695 template <
typename Key,
typename Alloc >
702 template <
typename Key,
typename Alloc >
704 return __inside.
size();
708 template <
typename Key,
typename Alloc >
710 return __inside.
empty();
714 template <
typename Key,
typename Alloc >
715 template <
typename OtherAlloc >
722 if (size() < h2.
size()) {
724 iter != __inside.cend();
726 if (h2.
exists(iter.key())) h_r.
insert(iter.key(),
true);
732 if (__inside.exists(iter.key())) h_r.
insert(iter.key(),
true);
741 template <
typename Key,
typename Alloc >
742 template <
typename OtherAlloc >
747 for (
auto iter = __inside.beginSafe(); iter != __inside.endSafe(); ++iter) {
748 if (!h2.
exists(iter.key())) __inside.erase(iter);
757 template <
typename Key,
typename Alloc >
758 template <
typename OtherAlloc >
763 if (!__inside.exists(pair.first)) __inside.
insert(pair.first,
true);
772 template <
typename Key,
typename Alloc >
773 template <
typename OtherAlloc >
782 if (!h_r.
exists(iter.key())) h_r.
insert(iter.key(),
true);
790 template <
typename Key,
typename Alloc >
791 template <
typename OtherAlloc >
799 iter != __inside.cend();
801 if (!h2.
exists(iter.key())) h_r.
insert(iter.key(),
true);
807 template <
typename Key,
typename Alloc >
809 std::stringstream out;
813 for (
iterator iter = begin(); iter != end(); ++iter) {
830 template <
typename Key,
typename Alloc >
831 std::ostream& operator<<(std::ostream& stream, const Set< Key, Alloc >&
set) {
832 stream <<
set.toString();
837 template <
typename Key,
typename Alloc >
838 template <
typename NewKey,
typename NewAlloc >
844 if (size == 0) size = std::max(
Size(2), __inside.size() / 2);
851 iter != __inside.cend();
853 table.insert(iter.key(), f(iter.key()));
860 template <
typename Key,
typename Alloc >
861 template <
typename NewKey,
typename NewAlloc >
867 if (size == 0) size = std::max(
Size(2), __inside.size() / 2);
874 iter != __inside.cend();
876 table.insert(iter.key(), val);
883 template <
typename Key,
typename Alloc >
884 template <
typename NewKey,
typename NewAlloc >
892 iter != __inside.cend();
902 template <
typename T,
typename Alloc >
906 for (
const auto& k: key) {
915 template <
typename T,
typename Alloc >
918 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.
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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.
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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.