ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
FlatMap.h File Reference

The sequences of ADS as the containers of std::flat_set and std::flat_map of C++23, beyond the book. More...

#include "ADS/sequence/TieredVector.h"
#include <cstddef>
#include <functional>
#include <iterator>
#include <utility>
#include <version>

Go to the source code of this file.

Classes

class  ADS::StdSequence< S >
 the sequence \( S \) of ADS, which inserts and erases by rank, with the members by iterator of a SequenceContainer, each one call of insert( i , x ) or erase( i ) of \( S \) at the rank \( i \) of the iterator More...

Namespaces

namespace  ADS

Detailed description

The sequences of ADS as the containers of std::flat_set and std::flat_map of C++23, beyond the book.

These keep their keys (and their values) sorted in any sequence container with random-access iterators, which they edit through the members by iterator of a SequenceContainer (insert( p , x ), emplace( p , ... ), erase( p ), erase( first , last )); TieredVector, RootishArrayStack, Treque, CubishArrayStack and DualArrayDeque have them, each one call of the operation by rank at the rank of the iterator, and StdSequence< S > adds them to any other sequence \( S \) of ADS that inserts and erases by rank (ContiguousDeque, whose iterators are pointers, so that its own insert( 0 , x ) would be ambiguous between a rank and a null pointer). TieredFlatSet and TieredFlatMap are the flat containers on TieredVector: a binary search on blocks of \( O( \sqrt{n} ) \) items as on a vector, and an insertion or an erasure in \( O( \sqrt{n} ) \) time instead of the \( O( n ) \) of std::vector, so that changing one template argument of a std::flat_map with many insertions brings it close to a search tree while it keeps the scans of an array.

See also
M. T. Goodrich, J. G. Kloss II, Tiered vectors: efficient dynamic arrays for rank-based sequences, WADS 1999, LNCS 1663, 205-216, doi:10.1007/3-540-48447-7_21
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa