\( n \) unsigned fields of \( B \) bits, \( 64 / B \) to a word, the values above \( 2^B - 1 \) clamped to it if Saturate
More...
#include <ADS/succinct/PackedArray.h>
|
| using | Word = std::uint64_t |
| | the type of the words
|
|
| | PackedArray (void)=default |
| | the empty array
|
| | PackedArray (std::size_t n, Word v=0) |
| | \( n \) fields of the value \( v \)
|
| template<Executor E, class F> |
| | PackedArray (E &ex, std::size_t n, F &&f) |
| | the fields f( i ) for \( i \in [ 0 , n ) \), filled by blocks of whole words on the threads of ex, \( O( n / p + \log n ) \) time on \( p \) threads
|
| | PackedArray (std::span< const Word > w, std::size_t n) |
| | the \( n \) fields of the words \( w \), the field \( i \) in the bits from \( ( i \bmod 64 / B ) B \) of the word \( \lfloor i B / 64
\rfloor \), as in words() (and in the int_vector of sdsl-lite); the bits past the last field are cleared
|
| std::size_t | size (void) const |
| | the number of fields, \( n \)
|
| bool | empty (void) const |
| | whether there is no field
|
| Word | get (std::size_t i) const |
| | the value of the field \( i \), the bits \( ( i \bmod 64 / B ) B \) on of the word \( \lfloor i B / 64 \rfloor \)
|
| Word | operator[] (std::size_t i) const |
| | as get( i )
|
| bool | set (std::size_t i, Word v) |
| | the field \( i \) set to \( v \), or to \( 2^B - 1 \) if \( v \) is larger and Saturate; true if \( v \) was clamped
|
| void | push_back (Word v) |
| | appends a field of the value \( v \), clamped if Saturate
|
| std::size_t | clamped (void) const |
| | the values clamped by the constructors, by set() and by push_back(), 0 unless Saturate
|
| const std::vector< Word > & | words (void) const |
| | the words, the field \( i \) in the word \( \lfloor i B / 64 \rfloor
\), the bits past the last field 0
|
| std::size_t | bytes (void) const |
| | the memory of the fields, in bytes
|
| template<class A> |
| void | persist (A &a) |
| | the members written to, or read from, the archive \( a \) [see Persistence.h]
|
|
| static constexpr std::uint64_t | persistTag (void) |
| | the width of the fields, in a file
|
|
| static constexpr std::size_t | PER = 64 / B |
| | the fields in a word
|
| static constexpr Word | MAX = ( Word( 1 ) << B ) - 1 |
| | the largest value of a field, \( 2^B - 1 \)
|
| static constexpr std::string_view | persistName = "PackedArray" |
| | the name of the structure in a file [see Persistence.h]
|
template<unsigned B, bool Saturate = false>
class ADS::PackedArray< B, Saturate >
\( n \) unsigned fields of \( B \) bits, \( 64 / B \) to a word, the values above \( 2^B - 1 \) clamped to it if Saturate
◆ Word
template<unsigned B, bool Saturate = false>
◆ PackedArray() [1/4]
template<unsigned B, bool Saturate = false>
◆ PackedArray() [2/4]
template<unsigned B, bool Saturate = false>
\( n \) fields of the value \( v \)
- Precondition
- \( v \le 2^B - 1 \) unless Saturate
◆ PackedArray() [3/4]
template<unsigned B, bool Saturate = false>
template<Executor E, class F>
the fields f( i ) for \( i \in [ 0 , n ) \), filled by blocks of whole words on the threads of ex, \( O( n / p + \log n ) \) time on \( p \) threads
In pseudocode (beyond the book), the words of \( W \) split in blocks by parallelForBlocks():
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{build}( \mathit{ex} , n , f ) \cr
2 & \quad \textbf{foreach}\ \text{block } [ a , b ) \text{ of the }
\text{words, in parallel}\ \textbf{do} \cr
3 & \qquad \textbf{for}\ w \gets a\ \textbf{to}\ b - 1\ \textbf{do} \cr
4 & \qquad\quad x \gets 0 \cr
5 & \qquad\quad \textbf{for}\ j \gets 0\ \textbf{to}\ \min\{ 64 / B ,
n - 64 w / B \} - 1\ \textbf{do} \cr
6 & \qquad\qquad x \gets x \vee ( \min\{ f( 64 w / B + j ) , 2^B - 1
\} \ll j B ) \cr
7 & \qquad\quad W[ w ] \gets x
\end{array}}
\]
- Precondition
- f( i ) is at most \( 2^B - 1 \) unless Saturate, and it may be called on any thread
◆ PackedArray() [4/4]
template<unsigned B, bool Saturate = false>
the \( n \) fields of the words \( w \), the field \( i \) in the bits from \( ( i \bmod 64 / B ) B \) of the word \( \lfloor i B / 64
\rfloor \), as in words() (and in the int_vector of sdsl-lite); the bits past the last field are cleared
- Precondition
- \( w \) holds \( \lceil n B / 64 \rceil \) words at least
◆ bytes()
template<unsigned B, bool Saturate = false>
the memory of the fields, in bytes
◆ clamped()
template<unsigned B, bool Saturate = false>
the values clamped by the constructors, by set() and by push_back(), 0 unless Saturate
◆ empty()
template<unsigned B, bool Saturate = false>
whether there is no field
◆ get()
template<unsigned B, bool Saturate = false>
the value of the field \( i \), the bits \( ( i \bmod 64 / B ) B \) on of the word \( \lfloor i B / 64 \rfloor \)
- Precondition
- \( i < n \)
◆ operator[]()
template<unsigned B, bool Saturate = false>
as get( i )
- Precondition
- \( i < n \)
◆ persist()
template<unsigned B, bool Saturate = false>
template<class A>
the members written to, or read from, the archive \( a \) [see Persistence.h]
◆ persistTag()
template<unsigned B, bool Saturate = false>
|
|
inlinestaticnodiscardconstexpr |
the width of the fields, in a file
◆ push_back()
template<unsigned B, bool Saturate = false>
appends a field of the value \( v \), clamped if Saturate
- Precondition
- \( v \le 2^B - 1 \) unless Saturate
◆ set()
template<unsigned B, bool Saturate = false>
the field \( i \) set to \( v \), or to \( 2^B - 1 \) if \( v \) is larger and Saturate; true if \( v \) was clamped
In pseudocode (beyond the book), \( s = ( i \bmod 64 / B ) B \):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{set}( i , v ) \cr
2 & \quad c \gets v > 2^B - 1;\ v \gets \min\{ v , 2^B - 1 \} \cr
3 & \quad W[ \lfloor i B / 64 \rfloor ] \gets ( W[ \lfloor i B / 64
\rfloor ] \wedge \neg( ( 2^B - 1 ) \ll s ) ) \vee ( v \ll s ) \cr
4 & \quad \textbf{return}\ c
\end{array}}
\]
- Precondition
- \( i < n \), and \( v \le 2^B - 1 \) unless Saturate
- Postcondition
- get( i ) is \( \min\{ v , 2^B - 1 \} \)
◆ size()
template<unsigned B, bool Saturate = false>
the number of fields, \( n \)
◆ words()
template<unsigned B, bool Saturate = false>
the words, the field \( i \) in the word \( \lfloor i B / 64 \rfloor
\), the bits past the last field 0
◆ operator==
template<unsigned B, bool Saturate = false>
whether the two arrays have the same fields
◆ MAX
template<unsigned B, bool Saturate = false>
the largest value of a field, \( 2^B - 1 \)
◆ PER
template<unsigned B, bool Saturate = false>
◆ persistName
template<unsigned B, bool Saturate = false>
The documentation for this class was generated from the following file: