|
ADS
Algorithms and Data Structures
|
The SET of the integers in \( [ 0 , N ) \) as a boolean vector of section 8.1: contains(), insert() and remove() in \( O( 1 ) \), min(), max() and forEach() in \( O( N ) \), union, intersection, difference and symmetric difference in \( \Theta( N ) \) (the first is called setUnion(), union being a keyword of C++, and so the others are setIntersection(), setDifference() and setSymmetricDifference()). More...
#include "ADS/Contract.h"#include "ADS/Iterators.h"#include "ADS/Simd.h"#include <algorithm>#include <bit>#include <concepts>#include <cstddef>#include <cstdint>#include <functional>#include <optional>#include <memory>#include <new>#include <stdexcept>#include <type_traits>#include <utility>#include <vector>#include "ADS/set/impl/BoolSet.tpp"Go to the source code of this file.
Classes | |
| class | ADS::BoolSet |
| a set of integers in \( [ 0 , N ) \) as a boolean vector More... | |
| struct | ADS::BoolSet::Places |
| the places of the table, for SlotIterator More... | |
Namespaces | |
| namespace | ADS |
Functions | |
| BoolSet | ADS::setUnion (const BoolSet &A, const BoolSet &B) |
| the union, a set of dimension \( \max( \mathrm{dim}( A ) , \mathrm{dim}( B ) ) \) | |
| BoolSet | ADS::setIntersection (const BoolSet &A, const BoolSet &B) |
| the intersection, a set of dimension \( \min( \mathrm{dim}( A ) , \mathrm{dim}( B ) ) \) | |
| BoolSet | ADS::setDifference (const BoolSet &A, const BoolSet &B) |
| the difference, a set of dimension A.dim() | |
| BoolSet | ADS::setSymmetricDifference (const BoolSet &A, const BoolSet &B) |
| the symmetric difference, the items in exactly one of \( A \) and \( B \), a set of dimension \( \max( \mathrm{dim}( A ) , \mathrm{dim}( B ) ) \) | |
The SET of the integers in \( [ 0 , N ) \) as a boolean vector of section 8.1: contains(), insert() and remove() in \( O( 1 ) \), min(), max() and forEach() in \( O( N ) \), union, intersection, difference and symmetric difference in \( \Theta( N ) \) (the first is called setUnion(), union being a keyword of C++, and so the others are setIntersection(), setDifference() and setSymmetricDifference()).
The vector is kept as words of 64 bits, and the operations of two sets and the scans of min(), max() and forEach() go a word at a time: the same loops on the \( N \) booleans, 64 of them in one operation of the processor, which leaves the bounds unchanged and divides the time by up to 64 (\( \lceil N / 64 \rceil \) operations on words for a set of dimension \( N \)); the size of a result is the count of its bits, in the same pass as the operation, with ADS_WITH_HIGHWAY by the kernel of the vectors of the processor [see Simd.h] (the count of the lanes of Highway, a table of half bytes as in the method of Muła, Kurz and Lemire where the processor has no count of its own), and the words of a result are written once, not filled with zeros before.
The contracts [see Contract.h]: \( N \ge 0 \), an item inserted is in \( [ 0 , N ) \), and each operation of two sets gives, item by item, what its name says; the invariant is that the size counts the bits set. The operations are defined in BoolSet.tpp.