\( n \) values in \( \{ 0 , 1 , 2 \} \), five to a byte in base 3
More...
#include <ADS/succinct/PackedArray.h>
|
| | TritArray (void)=default |
| | the empty array
|
| | TritArray (std::size_t n, unsigned v=0) |
| | \( n \) values \( v \)
|
| template<Executor E, class F> |
| | TritArray (E &ex, std::size_t n, F &&f) |
| | the values f( i ) for \( i \in [ 0 , n ) \), filled by blocks of whole bytes on the threads of ex
|
| std::size_t | size (void) const |
| | the number of values, \( n \)
|
| bool | empty (void) const |
| | whether there is no value
|
| unsigned | get (std::size_t i) const |
| | the value \( i \), the digit \( i \bmod 5 \) of the byte \( \lfloor i / 5 \rfloor \), from the table of the digits of the 243 bytes
|
| unsigned | operator[] (std::size_t i) const |
| | as get( i )
|
| void | set (std::size_t i, unsigned v) |
| | the value \( i \) set to \( v \)
|
| void | push_back (unsigned v) |
| | appends the value \( v \)
|
| const std::vector< std::uint8_t > & | data (void) const |
| | the bytes, five values each, those past the last value 0
|
| std::size_t | bytes (void) const |
| | the memory of the values, in bytes
|
| template<class A> |
| void | persist (A &a) |
| | the members written to, or read from, the archive \( a \) [see Persistence.h]
|
\( n \) values in \( \{ 0 , 1 , 2 \} \), five to a byte in base 3
◆ TritArray() [1/3]
| ADS::TritArray::TritArray |
( |
void | | ) |
|
|
default |
◆ TritArray() [2/3]
| ADS::TritArray::TritArray |
( |
std::size_t | n, |
|
|
unsigned | v = 0 ) |
|
explicit |
\( n \) values \( v \)
- Precondition
- \( v \le 2 \)
◆ TritArray() [3/3]
template<Executor E, class F>
| ADS::TritArray::TritArray |
( |
E & | ex, |
|
|
std::size_t | n, |
|
|
F && | f ) |
the values f( i ) for \( i \in [ 0 , n ) \), filled by blocks of whole bytes on the threads of ex
In pseudocode (Breyer and Korf, beyond the book), by blocks of bytes as PackedArray does by blocks of words:
\[\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{bytes, in parallel}\ \textbf{do} \cr
3 & \qquad \textbf{for}\ y \gets a\ \textbf{to}\ b - 1\ \textbf{do} \cr
4 & \qquad\quad x \gets 0 \cr
5 & \qquad\quad \textbf{for}\ j \gets \min\{ 5 , n - 5 y \} - 1
\ \textbf{downto}\ 0\ \textbf{do}\ x \gets 3 x + f( 5 y + j ) \cr
6 & \qquad\quad Y[ y ] \gets x
\end{array}}
\]
- Precondition
- f( i ) is at most 2, and it may be called on any thread
◆ bytes()
| std::size_t ADS::TritArray::bytes |
( |
void | | ) |
const |
|
inlinenodiscard |
the memory of the values, in bytes
◆ data()
| const std::vector< std::uint8_t > & ADS::TritArray::data |
( |
void | | ) |
const |
|
inlinenodiscard |
the bytes, five values each, those past the last value 0
◆ empty()
| bool ADS::TritArray::empty |
( |
void | | ) |
const |
|
inlinenodiscard |
whether there is no value
◆ get()
| unsigned ADS::TritArray::get |
( |
std::size_t | i | ) |
const |
|
nodiscard |
the value \( i \), the digit \( i \bmod 5 \) of the byte \( \lfloor i / 5 \rfloor \), from the table of the digits of the 243 bytes
- Precondition
- \( i < n \)
◆ operator[]()
| unsigned ADS::TritArray::operator[] |
( |
std::size_t | i | ) |
const |
|
inlinenodiscard |
as get( i )
- Precondition
- \( i < n \)
◆ persist()
template<class A>
| void ADS::TritArray::persist |
( |
A & | a | ) |
|
the members written to, or read from, the archive \( a \) [see Persistence.h]
◆ push_back()
| void ADS::TritArray::push_back |
( |
unsigned | v | ) |
|
appends the value \( v \)
- Precondition
- \( v \le 2 \)
◆ set()
| void ADS::TritArray::set |
( |
std::size_t | i, |
|
|
unsigned | v ) |
the value \( i \) set to \( v \)
In pseudocode (Breyer and Korf, beyond the book):
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{procedure}\ \mathrm{set}( i , v ) \cr
2 & \quad t \gets \mathrm{get}( i ) \cr
3 & \quad Y[ \lfloor i / 5 \rfloor ] \gets Y[ \lfloor i / 5 \rfloor ]
+ ( v - t ) \, 3^{i \bmod 5}
\end{array}}
\]
- Precondition
- \( i < n \) and \( v \le 2 \)
- Postcondition
- get( i ) is \( v \)
◆ size()
| std::size_t ADS::TritArray::size |
( |
void | | ) |
const |
|
inlinenodiscard |
the number of values, \( n \)
◆ operator==
whether the two arrays have the same values
◆ persistName
| std::string_view ADS::TritArray::persistName = "TritArray" |
|
staticconstexpr |
The documentation for this class was generated from the following file: