|
ADS
Algorithms and Data Structures
|
The indexed skip list, beyond the book: the skip list of Pugh [see SkipList.h] whose links carry their width, the number of keys they jump over, so that besides the operations of a DICTIONARY [see ADT.h] and the find(x) of an SSet of Morin (lowerBound()) it reaches a key by its rank, the number of keys smaller than it, and gives the rank of a key, both in \( O( \log n ) \) expected time (exercise 4.9 of Morin). More...
#include "ADS/Contract.h"#include "ADS/Iterators.h"#include "ADS/dictionary/RandomHashing.h"#include <algorithm>#include <bit>#include <concepts>#include <cstddef>#include <cstdint>#include <iterator>#include <memory>#include <new>#include <optional>#include <utility>#include "ADS/dictionary/impl/IndexedSkipList.tpp"Go to the source code of this file.
Classes | |
| class | ADS::IndexedSkipList< K, V > |
| a DICTIONARY on a skip list with the widths of the links, which reaches a key by its rank More... | |
| class | ADS::IndexedSkipList< K, V >::const_iterator |
| the iterator on the pairs, along the bottom level More... | |
Namespaces | |
| namespace | ADS |
The indexed skip list, beyond the book: the skip list of Pugh [see SkipList.h] whose links carry their width, the number of keys they jump over, so that besides the operations of a DICTIONARY [see ADT.h] and the find(x) of an SSet of Morin (lowerBound()) it reaches a key by its rank, the number of keys smaller than it, and gives the rank of a key, both in \( O( \log n ) \) expected time (exercise 4.9 of Morin).
A search by key sums the widths of the links it follows, which is the rank of the last node before the key; a search by rank goes along a level while the widths summed stay below the rank, as SkipListSequence does by index. An insertion splits the link that it crosses on each of its levels and adds 1 to the width of those that pass over it, a removal the reverse, so that the widths cost a constant factor on the plain skip list. A node is one block of memory, its key, its value and the tower of its links; the generator is SplitMix64 [see RandomHashing.h], seeded.
Morin gives no code for it: the benchmarks compare it with SkipList, whose operations it shares, to measure the price of the widths, one word per link and one addition per step.
The contracts [see Contract.h]: select() needs a rank below size(); insert() ensures that the key is there and remove() that it is not; the invariant, an \( O( n \log n ) \) check at the level 3, is the order of the keys and that the widths of each level sum to \( n + 1 \). The operations are defined in IndexedSkipList.tpp.