|
ADS
Algorithms and Data Structures
|
The SET as an unsorted LIST of section 8.2: contains(), insert() and remove() in \( O( n ) \), insertNew() in \( O( 1 ) \) when the item is known to be absent, the operations of two sets in \( O( n m ) \), which is optimal when the items can only be compared for equality (exercises 8.1 and 8.2). More...
#include "ADS/Contract.h"#include "ADS/sequence/List.h"#include "ADS/set/SetOperations.h"#include <algorithm>#include <concepts>#include <cstddef>#include <functional>#include <optional>#include <stdexcept>#include <utility>#include <vector>#include "ADS/set/impl/ListSet.tpp"Go to the source code of this file.
Classes | |
| class | ADS::ListSet< T > |
| a set as an unsorted list More... | |
Namespaces | |
| namespace | ADS |
Functions | |
| template<class T> | |
| ListSet< T > | ADS::setUnion (const ListSet< T > &A, const ListSet< T > &B) |
| the union: \( C \) starts as \( B \) and gets the items of \( A \) not in \( B \), inserted without looking for them in \( C \), \( O( n m ) \) time (exercise 8.2) | |
| template<class T> | |
| ListSet< T > | ADS::setIntersection (const ListSet< T > &A, const ListSet< T > &B) |
| the intersection, \( O( n m ) \) time (exercise 8.1) | |
| template<class T> | |
| ListSet< T > | ADS::setDifference (const ListSet< T > &A, const ListSet< T > &B) |
| the difference, \( O( n m ) \) time (the procedure of section 8.2) | |
| template<class T> | |
| ListSet< T > | ADS::setSymmetricDifference (const ListSet< T > &A, const ListSet< T > &B) |
| the symmetric difference, \( O( n m ) \) time (exercise 8.5) | |
The SET as an unsorted LIST of section 8.2: contains(), insert() and remove() in \( O( n ) \), insertNew() in \( O( 1 ) \) when the item is known to be absent, the operations of two sets in \( O( n m ) \), which is optimal when the items can only be compared for equality (exercises 8.1 and 8.2).
The contracts [see Contract.h]: insertNew() needs an item that is not there, after insert() the item is there and after remove() it is not, and each operation of two sets gives what its name says; the invariant is that no item is there twice. The operations are defined in ListSet.tpp.