60#ifndef __ADS_PackedArray
61 #define __ADS_PackedArray
94template<
unsigned B ,
bool Saturate = false >
98 static_assert( ( B == 1 ) || ( B == 2 ) || ( B == 4 ) || ( B == 8 ) ||
99 ( B == 16 ) || ( B == 32 ) ,
100 "a field of 1, 2, 4, 8, 16 or 32 bits" );
107 static constexpr std::size_t
PER = 64 / B;
141 template< Executor E ,
class F >
152 [[nodiscard]] std::size_t
size(
void )
const {
return( f_n ); }
155 [[nodiscard]]
bool empty(
void )
const {
return( f_n == 0 ); }
160 [[nodiscard]]
Word get( std::size_t i )
const;
189 [[nodiscard]] std::size_t
clamped(
void )
const {
return( f_clamped ); }
193 [[nodiscard]]
const std::vector< Word > &
words(
void )
const {
198 [[nodiscard]] std::size_t
bytes(
void )
const {
199 return( f_w.size() *
sizeof(
Word ) );
204 return( ( a.f_n == b.f_n ) && ( a.f_w == b.f_w ) );
213 [[nodiscard]]
static constexpr std::uint64_t
persistTag(
void ) {
214 return( detail::persistMix( { B , Saturate } ) );
225 [[nodiscard]]
bool clean(
void )
const;
227 std::vector< Word > f_w;
229 std::size_t f_clamped = 0;
268 template< Executor E ,
class F >
272 [[nodiscard]] std::size_t
size(
void )
const {
return( f_n ); }
275 [[nodiscard]]
bool empty(
void )
const {
return( f_n == 0 ); }
281 [[nodiscard]]
unsigned get( std::size_t i )
const;
302 void set( std::size_t i ,
unsigned v );
309 [[nodiscard]]
const std::vector< std::uint8_t > &
data(
void )
const {
314 [[nodiscard]] std::size_t
bytes(
void )
const {
return( f_y.size() ); }
318 return( ( a.f_n == b.f_n ) && ( a.f_y == b.f_y ) );
334 static constexpr std::array< std::array< std::uint8_t , 5 > , 243 > DIGITS =
336 std::array< std::array< std::uint8_t , 5 > , 243 > d{};
337 for(
int b = 0 ; b < 243 ; ++b )
338 for(
int j = 0 , x = b ; j < 5 ; ++j , x /= 3 )
339 d[ std::size_t( b ) ][ std::size_t( j ) ] = std::uint8_t( x % 3 );
344 static constexpr std::uint8_t POW3[ 5 ] = { 1 , 3 , 9 , 27 , 81 };
348 [[nodiscard]]
bool clean(
void )
const;
350 std::vector< std::uint8_t > f_y;
363#include "ADS/succinct/impl/PackedArray.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The layer of execution of the parallel algorithms of ADS, beyond the book: an executor runs the calls...
A file mapped in memory, shared by the structures that are read from it in place [see Persistence....
Word operator[](std::size_t i) const
as get( i )
Definition PackedArray.h:164
friend bool operator==(const PackedArray &a, const PackedArray &b)
whether the two arrays have the same fields
Definition PackedArray.h:203
static constexpr Word MAX
the largest value of a field,
Definition PackedArray.h:110
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
std::size_t clamped(void) const
the values clamped by the constructors, by set() and by push_back(), 0 unless Saturate
Definition PackedArray.h:189
std::uint64_t Word
the type of the words
Definition PackedArray.h:104
PackedArray(std::span< const Word > w, std::size_t n)
the fields of the words , the field in the bits from of the word , as in words() (and in the int_...
bool empty(void) const
whether there is no field
Definition PackedArray.h:155
PackedArray(std::size_t n, Word v=0)
fields of the value
std::size_t bytes(void) const
the memory of the fields, in bytes
Definition PackedArray.h:198
const std::vector< Word > & words(void) const
the words, the field in the word , the bits past the last field 0
Definition PackedArray.h:193
std::size_t size(void) const
the number of fields,
Definition PackedArray.h:152
PackedArray(void)=default
the empty array
PackedArray(E &ex, std::size_t n, F &&f)
the fields f( i ) for , filled by blocks of whole words on the threads of ex, time on threads
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition PackedArray.h:210
static constexpr std::size_t PER
the fields in a word
Definition PackedArray.h:107
static constexpr std::uint64_t persistTag(void)
the width of the fields, in a file
Definition PackedArray.h:213
bool set(std::size_t i, Word v)
the field set to , or to if is larger and Saturate; true if was clamped
Word get(std::size_t i) const
the value of the field , the bits on of the word
void push_back(Word v)
appends a field of the value , clamped if Saturate
const std::vector< std::uint8_t > & data(void) const
the bytes, five values each, those past the last value 0
Definition PackedArray.h:309
bool empty(void) const
whether there is no value
Definition PackedArray.h:275
friend bool operator==(const TritArray &a, const TritArray &b)
whether the two arrays have the same values
Definition PackedArray.h:317
static constexpr std::string_view persistName
the name of the structure in a file [see Persistence.h]
Definition PackedArray.h:324
TritArray(std::size_t n, unsigned v=0)
values
TritArray(E &ex, std::size_t n, F &&f)
the values f( i ) for , filled by blocks of whole bytes on the threads of ex
TritArray(void)=default
the empty array
void push_back(unsigned v)
appends the value
void persist(A &a)
the members written to, or read from, the archive [see Persistence.h]
unsigned operator[](std::size_t i) const
as get( i )
Definition PackedArray.h:285
std::size_t size(void) const
the number of values,
Definition PackedArray.h:272
void set(std::size_t i, unsigned v)
the value set to
std::size_t bytes(void) const
the memory of the values, in bytes
Definition PackedArray.h:314
unsigned get(std::size_t i) const
the value , the digit of the byte , from the table of the digits of the 243 bytes