ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::DictionarySet< D > Class Template Reference

a set on a DICTIONARY D, an item being a key: a USet of Morin if D is a KeyedDictionary, an SSet if it is an OrderedDictionary More...

#include <ADS/set/DictionarySet.h>

Public types

using Item = typename D::Key
 the type of the items

Public member functions

template<class... A>
requires std::constructible_from< D , A... >
 DictionarySet (A &&... a)
 the empty set on the dictionary D( a... )
std::size_t size (void) const
 the number of items, the keys of the dictionary
bool empty (void) const
 whether the set has no item
bool contains (const Item &x) const
 whether \( x \) is a key of the dictionary
bool insert (const Item &x)
 \( x \) into the set, as the key of the value true (or of the value made by default, for values that are not bool); true if it was not there
bool remove (const Item &x)
 \( x \) out of the set, the key removed from the dictionary
const Item * find (const Item &x) const
 the address of the item equal to \( x \), nil if none, by findKey() of the dictionary: the find( x ) of a USet of Morin
const Item * lowerBound (const Item &x) const
 the address of the smallest item not smaller than \( x \), nil if none, by lowerBoundKey() of the dictionary: the find( x ) of an SSet of Morin
template<class F>
void forEach (F &&f) const
 f( x ) on the items, in the order of the dictionary
const D & dictionary (void) const
 the dictionary
auto begin (void) const
 the iterator on the first key of the dictionary
auto end (void) const
 the iterator past the last key of the dictionary

Detailed description

template<class D>
class ADS::DictionarySet< D >

a set on a DICTIONARY D, an item being a key: a USet of Morin if D is a KeyedDictionary, an SSet if it is an OrderedDictionary

Member typedef documentation

◆ Item

template<class D>
using ADS::DictionarySet< D >::Item = typename D::Key

the type of the items

Constructor and destructor documentation

◆ DictionarySet()

template<class D>
template<class... A>
requires std::constructible_from< D , A... >
ADS::DictionarySet< D >::DictionarySet ( A &&... a)
explicit

the empty set on the dictionary D( a... )

Member function documentation

◆ begin()

template<class D>
auto ADS::DictionarySet< D >::begin ( void ) const
inlinenodiscard

the iterator on the first key of the dictionary

◆ contains()

template<class D>
bool ADS::DictionarySet< D >::contains ( const Item & x) const
nodiscard

whether \( x \) is a key of the dictionary

◆ dictionary()

template<class D>
const D & ADS::DictionarySet< D >::dictionary ( void ) const
nodiscard

the dictionary

◆ empty()

template<class D>
bool ADS::DictionarySet< D >::empty ( void ) const
nodiscard

whether the set has no item

◆ end()

template<class D>
auto ADS::DictionarySet< D >::end ( void ) const
inlinenodiscard

the iterator past the last key of the dictionary

◆ find()

template<class D>
const Item * ADS::DictionarySet< D >::find ( const Item & x) const
nodiscard

the address of the item equal to \( x \), nil if none, by findKey() of the dictionary: the find( x ) of a USet of Morin

◆ forEach()

template<class D>
template<class F>
void ADS::DictionarySet< D >::forEach ( F && f) const

f( x ) on the items, in the order of the dictionary

◆ insert()

template<class D>
bool ADS::DictionarySet< D >::insert ( const Item & x)

\( x \) into the set, as the key of the value true (or of the value made by default, for values that are not bool); true if it was not there

In pseudocode (section 8.4), \( D \) the dictionary:

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{insert}( x )\quad \triangleright \ \text{true if } x \text{ is new} \cr 2 & \quad \textbf{if}\ \text{the insertion of } D \text{ tells whether the key was new}\ \textbf{then return} \ D.\mathrm{insert}( x , \textbf{true} ) \cr 3 & \quad \mathit{fresh} \gets \textbf{not}\ \mathrm{contains}( x ); \ \textbf{if}\ \mathit{fresh}\ \textbf{then}\ D.\mathrm{insert}( x , \textbf{true} ) \cr 4 & \quad \textbf{return}\ \mathit{fresh} \end{array}} \]

Postcondition
\( x \) is in the set

◆ lowerBound()

template<class D>
const Item * ADS::DictionarySet< D >::lowerBound ( const Item & x) const
nodiscard

the address of the smallest item not smaller than \( x \), nil if none, by lowerBoundKey() of the dictionary: the find( x ) of an SSet of Morin

◆ remove()

template<class D>
bool ADS::DictionarySet< D >::remove ( const Item & x)

\( x \) out of the set, the key removed from the dictionary

In pseudocode (section 8.4):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{remove}( x )\quad \triangleright \ \text{true if } x \text{ was there} \cr 2 & \quad \textbf{if}\ \text{the removal of } D \text{ tells whether the key was there}\ \textbf{then return} \ D.\mathrm{remove}( x ) \cr 3 & \quad \mathit{found} \gets \mathrm{contains}( x );\ \textbf{if} \ \mathit{found}\ \textbf{then}\ D.\mathrm{remove}( x ) \cr 4 & \quad \textbf{return}\ \mathit{found} \end{array}} \]

Postcondition
\( x \) is not in the set

◆ size()

template<class D>
std::size_t ADS::DictionarySet< D >::size ( void ) const
nodiscard

the number of items, the keys of the dictionary


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