ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
SetOperations.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/*-------------------------- File SetOperations.h --------------------------*/
3/*--------------------------------------------------------------------------*/
31/*--------------------------------------------------------------------------*/
32/*----------------------------- DEFINITIONS --------------------------------*/
33/*--------------------------------------------------------------------------*/
34
35#ifndef __ADS_SetOperations
36 #define __ADS_SetOperations
37/* self-identification: #endif constant */
38
39/*--------------------------------------------------------------------------*/
40/*------------------------------ INCLUDES ----------------------------------*/
41/*--------------------------------------------------------------------------*/
42
43#include "ADS/ADT.h"
44#include "ADS/Contract.h"
45
46#include <algorithm>
47#include <concepts>
48#include <cstddef>
49#include <functional>
50#include <optional>
51#include <stdexcept>
52#include <utility>
53#include <vector>
54
55/*--------------------------------------------------------------------------*/
56/*--------------------------- NAMESPACE ------------------------------------*/
57/*--------------------------------------------------------------------------*/
58
59namespace ADS
60{
61
62/*--------------------------------------------------------------------------*/
63/*--------------------------- GENERIC OPERATIONS ---------------------------*/
64/*--------------------------------------------------------------------------*/
65
67template< class S >
68concept IterableSet =
69 Set< S > && std::copy_constructible< S > &&
70 requires( const S s )
71{ s.forEach( []( const typename S::Item & ) { } ); };
72
85template< IterableSet S >
86S setUnion( const S & A , const S & B );
87
103template< IterableSet S >
104S setIntersection( const S & A , const S & B );
105
118template< IterableSet S >
119S setDifference( const S & A , const S & B );
120
135template< IterableSet S >
136S setSymmetricDifference( const S & A , const S & B );
137
138namespace detail
139{
140
147template< class C , class A , class B >
148bool isSetOperation( const C & c , const A & a , const B & b , char op );
149
150} // end( namespace detail )
151
152} // end( namespace ADS )
153
154/*--------------------------------------------------------------------------*/
155/*-------------------------- IMPLEMENTATION --------------------------------*/
156/*--------------------------------------------------------------------------*/
157
158#include "ADS/set/impl/SetOperations.tpp"
159
160/*--------------------------------------------------------------------------*/
161
162#endif /* SetOperations.h included */
163
164/*--------------------------------------------------------------------------*/
165/*------------------------ End File SetOperations.h ------------------------*/
166/*--------------------------------------------------------------------------*/
The abstract data types of the book, as concepts of C++20: SEQUENCE, SET and DICTIONARY (chapter 3),...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
a SET that can be copied and has the foreach
Definition SetOperations.h:68
SET (section 3.2.2): a finite collection of distinct items; union(), intersection() and difference() ...
Definition ADT.h:140
BoolSet setIntersection(const BoolSet &A, const BoolSet &B)
the intersection, a set of dimension
BoolSet setUnion(const BoolSet &A, const BoolSet &B)
the union, a set of dimension
BoolSet setDifference(const BoolSet &A, const BoolSet &B)
the difference, a set of dimension A.dim()
BoolSet setSymmetricDifference(const BoolSet &A, const BoolSet &B)
the symmetric difference, the items in exactly one of and , a set of dimension
Definition ADT.h:96