ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::Set Concept Reference

SET (section 3.2.2): a finite collection of distinct items; union(), intersection() and difference() are functions of two sets. More...

#include <ADS/ADT.h>

Concept definition

template< class S >
concept Set = requires( S s , const S cs , const typename S::Item & x )
{
typename S::Item;
{ cs.size() } -> std::convertible_to< std::size_t >;
{ cs.contains( x ) } -> std::same_as< bool >;
s.insert( x );
s.remove( x );
}
SET (section 3.2.2): a finite collection of distinct items; union(), intersection() and difference() ...
Definition ADT.h:140

Detailed description

SET (section 3.2.2): a finite collection of distinct items; union(), intersection() and difference() are functions of two sets.

As axioms, \( \mathrm{contains}( x , \mathrm{create} ) = \mathbf{false} \), \( \mathrm{contains}( x , \mathrm{insert}( y , A ) ) = ( x = y ) \lor \mathrm{contains}( x , A ) \), \( \mathrm{contains}( x , \mathrm{remove}( y , A ) ) = ( x \neq y ) \land \mathrm{contains}( x , A ) \); inserting an item already there, and removing one that is not, leave the set as it is (a relaxation of the preconditions \( x \notin A \) and \( x \in A \) that some specifications state)