Spicy
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
hilti::rt::Set< T > Class Template Reference

#include <set.h>

Inheritance diagram for hilti::rt::Set< T >:

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)
 
Setoperator= (const Set &)=default
 
Setoperator= (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

_control = std::make_shared<Set<T>*>(this)
 

Friends

bool operator== (const Set &a, const Set &b)
 
bool operator!= (const Set &a, const Set &b)
 

Detailed Description

template<typename T>
class hilti::rt::Set< T >

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 dereferenceable iterators.
set.insert(1);

*it; // Iterator now invalid, throws.

If not otherwise specified, member functions have the semantics of std::set member functions.

Member Function Documentation

◆ clear()

template<typename T>
void hilti::rt::Set< T >::clear ( )
inline

Erases all elements from the set.

This function invalidates all iterators into the set.

◆ contains()

template<typename T>
bool hilti::rt::Set< T >::contains ( const T &  t) const
inline

Checks whether an element is in the set.

Parameters
<tt>t</tt>the element to check for
Returns
true if the element is part of the set.

◆ erase()

template<typename T>
size_type hilti::rt::Set< T >::erase ( const key_type &  key)
inline

Removes an element from the set.

This function invalidates all iterators into the set.

Parameters
keythe element to remove
Returns
1 if the element was in the set, 0 otherwise

◆ insert()

template<typename T>
iterator hilti::rt::Set< T >::insert ( iterator  hint,
const T &  value 
)
inline

Inserts value in the position as close as possible to hint.

Parameters
hinthint for the insertion position
valuevalue to insert
Returns
iterator pointing to the inserted element

The documentation for this class was generated from the following file: