JASSv2
Public Member Functions | Static Public Member Functions | Static Private Attributes | List of all members
JASS::compress_integer_bitpack Class Reference

Fixed-width pack integers into as few 256-bit SIMD words as possible. More...

#include <compress_integer_bitpack.h>

Inheritance diagram for JASS::compress_integer_bitpack:
Inheritance graph
[legend]
Collaboration diagram for JASS::compress_integer_bitpack:
Collaboration graph
[legend]

Public Member Functions

template<int32_t WIDTH_IN_BITS>
size_t encode (void *encoded, size_t encoded_buffer_length, const integer *array, size_t source_integers, const uint32_t *bits_to_use=bits_to_use_complete, const uint32_t *selector_to_use=selector_to_use_complete)
 Encode a sequence of integers returning the number of bytes used for the encoding, or 0 if the encoded sequence doesn't fit in the buffer. More...
 
- Public Member Functions inherited from JASS::compress_integer
 compress_integer ()
 Constructor.
 
virtual ~compress_integer ()
 Destructor.
 
virtual size_t encode (void *encoded, size_t encoded_buffer_length, const integer *source, size_t source_integers)=0
 Encode a sequence of integers returning the number of bytes used for the encoding, or 0 if the encoded sequence doesn't fit in the buffer. More...
 
virtual void decode (integer *decoded, size_t integers_to_decode, const void *source, size_t source_length)=0
 Decode a sequence of integers encoded with this codex. More...
 

Static Public Member Functions

static uint32_t bits_needed (uint32_t integer)
 retur the number of bits needed to represent the given integer. More...
 
- Static Public Member Functions inherited from JASS::compress_integer
static size_t d1_encode (integer *encoded, const integer *source, size_t source_integers)
 Convert an array of integers into an array of D1 (delta, d-gap) encoded integers. More...
 
static size_t d1_decode (integer *decoded, const integer *source, size_t source_integers)
 Convert a D1 encoded array of integers into an array of integers. More...
 
static size_t dn_encode (integer *encoded, const integer *source, size_t source_integers, size_t n=1)
 Convert an array of integers into an array of Dn (delta, d-gap) encoded integers with a gap of n. More...
 
static size_t dn_decode (integer *decoded, const integer *source, size_t source_integers, size_t n=1)
 Convert a Dn encoded array of integers into an array of integers. More...
 
static void unittest_one (compress_integer &encoder, const std::vector< uint32_t > &sequence)
 Test one sequence to make sure it encodes and decodes to the same thing. Assert if not. More...
 
static void unittest (compress_integer &compressor, uint32_t staring_from=0)
 Unit test this class, assert on failure. More...
 

Static Private Attributes

static const uint32_t bits_to_use_complete []
 bits to use (column 1 ) for bits in integer (right column)
 
static const uint32_t selector_to_use_complete []
 selector to use (column 1 ) for bits in integer (right column)
 

Additional Inherited Members

- Public Types inherited from JASS::compress_integer
typedef uint32_t integer
 This class and descendants will work on integers of this size. Do not change without also changing JASS_COMPRESS_INTEGER_BITS_PER_INTEGER.
 

Detailed Description

Fixed-width pack integers into as few 256-bit SIMD words as possible.

Pack into n * 32-bit worda a bunch of same-width integers, so: 32 * 8 * 1-bit integers 16 * 8 * 2-bit integers 10 * 8 * 3-bit integers 8 * 8 * 4-bit integers 6 * 8 * 5-bit integers 5 * 8 * 6-bit integers 4 * 8 * 8-bit integers 3 * 8 * 10-bit integers 2 * 8 * 16-bit integers 1 * 8 * 32-bit integers

Member Function Documentation

◆ bits_needed()

static uint32_t JASS::compress_integer_bitpack::bits_needed ( uint32_t  integer)
inlinestatic

retur the number of bits needed to represent the given integer.

Parameters
integer[in] The integer to be represented. The number of bits neeeded.

◆ encode()

template<int32_t WIDTH_IN_BITS>
size_t JASS::compress_integer_bitpack::encode ( void *  encoded,
size_t  encoded_buffer_length,
const integer array,
size_t  source_integers,
const uint32_t *  bits_to_use = bits_to_use_complete,
const uint32_t *  selector_to_use = selector_to_use_complete 
)
inline

Encode a sequence of integers returning the number of bytes used for the encoding, or 0 if the encoded sequence doesn't fit in the buffer.

Template Parameters
WIDTH_IN_BITSThe size of the machine word (in bits).
Parameters
encoded[out] The sequence of bytes that is the encoded sequence.
encoded_buffer_length[in] The length (in bytes) of the output buffer, encoded.
array[in] The sequence of integers to encode.
source_integers[in] The length (in integers) of the source buffer.
bits_to_use[in] the array of bit-widths to use.
selector_to_use[in] The array of selectors to use.
Returns
The number of bytes used to encode the integer sequence, or 0 on error (i.e. overflow).

The documentation for this class was generated from the following files: