BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
belfem::Set< Key > Class Template Reference

Hash set with set operations. More...

#include <cl_Set.hpp>

Public Types

using iterator = typename std::unordered_set< Key >::iterator
using const_iterator = typename std::unordered_set< Key >::const_iterator

Public Member Functions

 Set ()=default
 Empty constructor.
 Set (std::initializer_list< Key > aInit)
 Constructor with initializer list.
template<typename InputIt>
 Set (InputIt aFirst, InputIt aLast)
 Constructor from iterators.
 Set (const Set< Key > &aSet)=default
 Copy constructor.
 Set (Set< Key > &&aSet) noexcept=default
 Move constructor.
Set< Key > & operator= (const Set< Key > &aSet)=default
 Copy assignment operator.
Set< Key > & operator= (Set< Key > &&aSet) noexcept=default
 Move assignment operator.
 ~Set ()=default
 Destructor.
void clear ()
 Clear the set.
size_t size () const
 Returns the size of the set.
bool empty () const
 Check if set is empty.
std::pair< iterator, bool > insert (const Key &aKey)
 Insert a key into the set.
std::pair< iterator, bool > insert (Key &&aKey)
 Insert a key using move semantics.
template<typename InputIt>
void insert (InputIt aFirst, InputIt aLast)
 Insert a range of elements.
template<typename... Args>
std::pair< iterator, bool > emplace (Args &&... args)
 Emplace a key (construct in-place).
bool key_exists (const Key &aKey) const
 Check if a key exists in the set.
bool contains (const Key &aKey) const
 Alternative name for key_exists (more set-like).
size_t count (const Key &aKey) const
 Count occurrences of key (0 or 1 for set).
iterator find (const Key &aKey)
 Find an element.
const_iterator find (const Key &aKey) const
 Find an element (const version).
size_t erase (const Key &aKey)
 Erase a key from the set.
iterator erase (const_iterator aPos)
 Erase an element by iterator.
iterator erase (const_iterator aFirst, const_iterator aLast)
 Erase a range of elements.
void reserve (size_t n)
 Reserve space for at least n elements.
iterator begin ()
 Get begin iterator.
const_iterator begin () const
 Get begin iterator (const).
iterator end ()
 Get end iterator.
const_iterator end () const
 Get end iterator (const).
std::unordered_set< Key > & set_data ()
 Expose the underlying container.
const std::unordered_set< Key > & set_data () const
 Expose the underlying container (const).
void swap (Set< Key > &aOther)
 Swap contents with another set.
Set< Key > operator| (const Set< Key > &aOther) const
 Set union operation.
Set< Key > operator& (const Set< Key > &aOther) const
 Set intersection operation.
Set< Key > operator- (const Set< Key > &aOther) const
 Set difference operation.
Set< Key > operator^ (const Set< Key > &aOther) const
 Set symmetric difference operation.
bool is_subset_of (const Set< Key > &aOther) const
 Check if this is a subset of another set.
bool is_superset_of (const Set< Key > &aOther) const
 Check if this is a superset of another set.
bool operator== (const Set< Key > &aOther) const
 Equality operator.
bool operator!= (const Set< Key > &aOther) const
 Inequality operator.

Detailed Description

template<typename Key>
class belfem::Set< Key >

Hash set with set operations.

See also
BELFEM Container Classes - Usage Guide

Member Typedef Documentation

◆ const_iterator

template<typename Key>
using belfem::Set< Key >::const_iterator = typename std::unordered_set< Key >::const_iterator

◆ iterator

template<typename Key>
using belfem::Set< Key >::iterator = typename std::unordered_set< Key >::iterator

Constructor & Destructor Documentation

◆ Set() [1/5]

template<typename Key>
belfem::Set< Key >::Set ( )
default

Empty constructor.

◆ Set() [2/5]

template<typename Key>
belfem::Set< Key >::Set ( std::initializer_list< Key > aInit)
inline

Constructor with initializer list.

◆ Set() [3/5]

template<typename Key>
template<typename InputIt>
belfem::Set< Key >::Set ( InputIt aFirst,
InputIt aLast )
inline

Constructor from iterators.

◆ Set() [4/5]

template<typename Key>
belfem::Set< Key >::Set ( const Set< Key > & aSet)
default

Copy constructor.

◆ Set() [5/5]

template<typename Key>
belfem::Set< Key >::Set ( Set< Key > && aSet)
defaultnoexcept

Move constructor.

◆ ~Set()

template<typename Key>
belfem::Set< Key >::~Set ( )
default

Destructor.

Member Function Documentation

◆ begin() [1/2]

template<typename Key>
iterator belfem::Set< Key >::begin ( )
inline

Get begin iterator.

◆ begin() [2/2]

template<typename Key>
const_iterator belfem::Set< Key >::begin ( ) const
inline

Get begin iterator (const).

◆ clear()

template<typename Key>
void belfem::Set< Key >::clear ( )
inline

Clear the set.

◆ contains()

template<typename Key>
bool belfem::Set< Key >::contains ( const Key & aKey) const
inline

Alternative name for key_exists (more set-like).

◆ count()

template<typename Key>
size_t belfem::Set< Key >::count ( const Key & aKey) const
inline

Count occurrences of key (0 or 1 for set).

◆ emplace()

template<typename Key>
template<typename... Args>
std::pair< iterator, bool > belfem::Set< Key >::emplace ( Args &&... args)
inline

Emplace a key (construct in-place).

◆ empty()

template<typename Key>
bool belfem::Set< Key >::empty ( ) const
inline

Check if set is empty.

◆ end() [1/2]

template<typename Key>
iterator belfem::Set< Key >::end ( )
inline

Get end iterator.

◆ end() [2/2]

template<typename Key>
const_iterator belfem::Set< Key >::end ( ) const
inline

Get end iterator (const).

◆ erase() [1/3]

template<typename Key>
size_t belfem::Set< Key >::erase ( const Key & aKey)
inline

Erase a key from the set.

Returns
number of elements removed (0 or 1)

◆ erase() [2/3]

template<typename Key>
iterator belfem::Set< Key >::erase ( const_iterator aFirst,
const_iterator aLast )
inline

Erase a range of elements.

◆ erase() [3/3]

template<typename Key>
iterator belfem::Set< Key >::erase ( const_iterator aPos)
inline

Erase an element by iterator.

◆ find() [1/2]

template<typename Key>
iterator belfem::Set< Key >::find ( const Key & aKey)
inline

Find an element.

◆ find() [2/2]

template<typename Key>
const_iterator belfem::Set< Key >::find ( const Key & aKey) const
inline

Find an element (const version).

◆ insert() [1/3]

template<typename Key>
std::pair< iterator, bool > belfem::Set< Key >::insert ( const Key & aKey)
inline

Insert a key into the set.

Returns
pair of iterator and bool (true if inserted, false if already existed)

◆ insert() [2/3]

template<typename Key>
template<typename InputIt>
void belfem::Set< Key >::insert ( InputIt aFirst,
InputIt aLast )
inline

Insert a range of elements.

◆ insert() [3/3]

template<typename Key>
std::pair< iterator, bool > belfem::Set< Key >::insert ( Key && aKey)
inline

Insert a key using move semantics.

◆ is_subset_of()

template<typename Key>
bool belfem::Set< Key >::is_subset_of ( const Set< Key > & aOther) const
inline

Check if this is a subset of another set.

◆ is_superset_of()

template<typename Key>
bool belfem::Set< Key >::is_superset_of ( const Set< Key > & aOther) const
inline

Check if this is a superset of another set.

◆ key_exists()

template<typename Key>
bool belfem::Set< Key >::key_exists ( const Key & aKey) const
inline

Check if a key exists in the set.

◆ operator!=()

template<typename Key>
bool belfem::Set< Key >::operator!= ( const Set< Key > & aOther) const
inline

Inequality operator.

◆ operator&()

template<typename Key>
Set< Key > belfem::Set< Key >::operator& ( const Set< Key > & aOther) const
inline

Set intersection operation.

Returns
new set containing only common elements

◆ operator-()

template<typename Key>
Set< Key > belfem::Set< Key >::operator- ( const Set< Key > & aOther) const
inline

Set difference operation.

Returns
new set containing elements in this but not in other

◆ operator=() [1/2]

template<typename Key>
Set< Key > & belfem::Set< Key >::operator= ( const Set< Key > & aSet)
default

Copy assignment operator.

◆ operator=() [2/2]

template<typename Key>
Set< Key > & belfem::Set< Key >::operator= ( Set< Key > && aSet)
defaultnoexcept

Move assignment operator.

◆ operator==()

template<typename Key>
bool belfem::Set< Key >::operator== ( const Set< Key > & aOther) const
inline

Equality operator.

◆ operator^()

template<typename Key>
Set< Key > belfem::Set< Key >::operator^ ( const Set< Key > & aOther) const
inline

Set symmetric difference operation.

Returns
new set containing elements in either set but not both

◆ operator|()

template<typename Key>
Set< Key > belfem::Set< Key >::operator| ( const Set< Key > & aOther) const
inline

Set union operation.

Returns
new set containing elements from both sets

◆ reserve()

template<typename Key>
void belfem::Set< Key >::reserve ( size_t n)
inline

Reserve space for at least n elements.

◆ set_data() [1/2]

template<typename Key>
std::unordered_set< Key > & belfem::Set< Key >::set_data ( )
inline

Expose the underlying container.

◆ set_data() [2/2]

template<typename Key>
const std::unordered_set< Key > & belfem::Set< Key >::set_data ( ) const
inline

Expose the underlying container (const).

◆ size()

template<typename Key>
size_t belfem::Set< Key >::size ( ) const
inline

Returns the size of the set.

◆ swap()

template<typename Key>
void belfem::Set< Key >::swap ( Set< Key > & aOther)
inline

Swap contents with another set.


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