![]() |
Spicy
|
#include <set.h>
Public Types | |
using | V = std::set< T > |
using | C = std::shared_ptr< Set< T > * > |
using | reference = const T & |
using | const_reference = const T & |
using | iterator = typename set::Iterator< T > |
using | const_iterator = typename set::Iterator< T > |
using | key_type = T |
using | value_type = T |
using | size_type = integer::safe< uint64_t > |
Public Member Functions | |
Set (const Set &)=default | |
Set (Set &&) noexcept=default | |
Set (const Vector< T > &l) | |
Set (std::initializer_list< T > l) | |
Set & | operator= (const Set &)=default |
Set & | operator= (Set &&) noexcept=default |
bool | contains (const T &t) const |
auto | begin () const |
auto | end () const |
size_type | size () const |
size_type | erase (const key_type &key) |
void | clear () |
iterator | insert (iterator hint, const T &value) |
Public Attributes | |
C | _control = std::make_shared<Set<T>*>(this) |
Friends | |
bool | operator== (const Set &a, const Set &b) |
bool | operator!= (const Set &a, const Set &b) |
HILTI's Set
is a std::set
-like type with additional safety guarantees.
In particular it guarantees that iterators are either valid, or throw an exception when accessed.
If not otherwise specified, we follow the semantics on iterator invalidation of std::set
with the caveat that iterators which cannot be dereferenced can become invalid through mutating Set
operations. We still validate invalid dereferencing of such iterators.
rt::Set<int> set; auto it = set.begin(); // Valid iterator which cannot be dereferenced. // Mutating the set invalidates not dereferencable iterators. set.insert(1); *it; // Iterator now invalid, throws.
If not otherwise specified, member functions have the semantics of std::set
member functions.
|
inline |
Erases all elements from the set.
This function invalidates all iterators into the set.
|
inline |
Checks whether an element is in the set.
<tt>t</tt> | the element to check for |
true
if the element is part of the set.
|
inline |
Removes an element from the set.
This function invalidates all iterators into the set.
key | the element to remove |
|
inline |
Inserts value in the position as close as possible to hint.
hint | hint for the insertion position |
value | value to insert |