|
ADS
Algorithms and Data Structures
|
The vectors of bits and of fields of ADS to and from those of sdsl-lite (its version 3, https://github.com/xxsds/sdsl-lite, header-only and under the BSD license), so that a structure of either library is built on the data of the other: an FM-index, a wavelet tree or a compressed suffix array of sdsl over a BitVector or a PackedArray of ADS, a RankSelect, an EliasFano or a WaveletMatrix of ADS over a bit_vector or an int_vector of sdsl. More...
#include "ADS/Contract.h"#include "ADS/parallel/Executor.h"#include "ADS/succinct/BitVector.h"#include "ADS/succinct/PackedArray.h"#include <sdsl/int_vector.hpp>#include <cstddef>#include <cstdint>#include <cstring>#include <span>#include <stdexcept>Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Functions | |
| sdsl::bit_vector | ADS::toSdsl (const BitVector &b) |
| the bits of \( b \) as a bit_vector of sdsl-lite, by a copy of the words | |
| BitVector | ADS::toBitVector (const sdsl::bit_vector &v) |
| the bits of the bit_vector \( v \) of sdsl-lite as a BitVector, by a copy of the words | |
| template<unsigned B, bool S> | |
| sdsl::int_vector< B > | ADS::toSdsl (const PackedArray< B, S > &a) |
| the fields of \( a \) as an int_vector< B > of sdsl-lite, by a copy of the words | |
| template<unsigned B, bool S = false, std::uint8_t W> | |
| PackedArray< B, S > | ADS::toPackedArray (const sdsl::int_vector< W > &v) |
| the fields of the int_vector \( v \) of sdsl-lite as a PackedArray< B , S >: by a copy of the words if its width is \( B \), and else field by field, each clamped to \( 2^B - 1 \) if \( S \) | |
The vectors of bits and of fields of ADS to and from those of sdsl-lite (its version 3, https://github.com/xxsds/sdsl-lite, header-only and under the BSD license), so that a structure of either library is built on the data of the other: an FM-index, a wavelet tree or a compressed suffix array of sdsl over a BitVector or a PackedArray of ADS, a RankSelect, an EliasFano or a WaveletMatrix of ADS over a bit_vector or an int_vector of sdsl.
The two libraries keep the bits in the same words: the bit \( i \) of a BitVector and of a bit_vector is the bit \( i \bmod 64 \) of the word \( \lfloor i / 64 \rfloor \), and the field \( i \) of a PackedArray< B > and of an int_vector< B > (or of an int_vector<> of width \( B \)) takes the bits \( i B \) to \( ( i + 1 ) B - 1 \), which never cross a word since \( B \) divides 64. Hence a conversion copies the words at once, \( \lceil n B / 64 \rceil \) of them, and clears the bits past the last field; only an int_vector of another width is read field by field. Neither library can take the words of the other without copy, since each one owns its words (ADS aligns them to a line of the cache, and sdsl allocates them by its own memory manager).
The same vectors of bits are also written to and read from the archives of cereal by both libraries, in the same form [see ADS/interop/cereal/Cereal.h], so that a BitVector saved by ADS is loaded as a bit_vector by sdsl and the converse.
This header is of the set interop: no entry point of ADS includes it, and it needs the headers of sdsl-lite 3, found by CMake when ADS_WITH_SDSL is AUTO or ON.