|
ADS
Algorithms and Data Structures
|
The operations of chapter 8 on any SET that can be copied and has the foreach, forEach( f ): the union copies \( A \) and inserts the items of \( B \), the intersection copies the smaller set and removes its items not in the other one, the difference copies \( A \) and removes its items in \( B \), the symmetric difference adds to \( A \setminus B \) the items of \( B \) not in \( A \). More...
#include "ADS/ADT.h"#include "ADS/Contract.h"#include <algorithm>#include <concepts>#include <cstddef>#include <functional>#include <optional>#include <stdexcept>#include <utility>#include <vector>#include "ADS/set/impl/SetOperations.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Concepts | |
| concept | ADS::IterableSet |
| a SET that can be copied and has the foreach | |
Functions | |
| template<IterableSet S> | |
| S | ADS::setUnion (const S &A, const S &B) |
| the union: a copy of \( A \), plus the items of \( B \) | |
| template<IterableSet S> | |
| S | ADS::setIntersection (const S &A, const S &B) |
| the intersection: a copy of the smaller set \( X \), less its items not in the other one, \( Y \) | |
| template<IterableSet S> | |
| S | ADS::setDifference (const S &A, const S &B) |
| the difference: a copy of \( A \), less its items in \( B \) | |
| template<IterableSet S> | |
| S | ADS::setSymmetricDifference (const S &A, const S &B) |
| the symmetric difference: \( A \setminus B \), plus the items of \( B \) not in \( A \) | |
The operations of chapter 8 on any SET that can be copied and has the foreach, forEach( f ): the union copies \( A \) and inserts the items of \( B \), the intersection copies the smaller set and removes its items not in the other one, the difference copies \( A \) and removes its items in \( B \), the symmetric difference adds to \( A \setminus B \) the items of \( B \) not in \( A \).
On the hash tables, with \( n_X \) keys in a table of size \( m_X \), they take \( O( \max( m_A , n_A ) + \max( m_B , n_B ) ) \) expected time (exercise 8.6), on the Red-Black trees \( O( n + m \log( n + m ) ) \) (exercise 8.7). The realizations that do better have their own [see BoolSet.h, ListSet.h and SortedListSet.h].
The contracts [see Contract.h]: the result of each operation holds, item by item, what its name says, an audit [see detail::isSetOperation()]. The operations are defined in SetOperations.tpp.