ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral > Class Template Reference

Description:

template<typename TIntegral>
class alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >

Helper-class that allows access the array data. The design goal for introducing this class (instead of providing array references in the interface methods) is to allow a minimum of flexibility in respect to the data provision, while not using callback functions (or virtual methods) to access each single array element.

The approach implemented here, allows the array value to be a single attribute residing in an array of structs. For this, besides a base pointer to the first value and the length of the array, the distance between two values within the array of structs (or classes) has to be given.

By nature, to do this, basic pointer manipulation is needed, which imposes the need using char* values internally, which are cast back to the source type with setters/getters.
Consequently, templated constructors are given, which accept array types to restrict such pointer conversion within the type.

Note
In the case an application uses a more complex data scheme for storing array data to be compressed, which are not accessible with this simple mechanism, such data has to be written into temporary arrays before compression.

Besides this, this accessor type, provides a transparent inline conversion of signed integer values to its unsigned counterparts by performing "zig zag encoding".

Template Parameters
TIntegralThe integral array type.

Definition at line 69 of file ac.inl.

Public Type Index:

using TUI = typename std::make_unsigned<TIntegral>::type
 The unsigned version of template type TIntegral.
 

Public Field Index:

TUI max
 Maximum value (when zig-zag encoded)
 
TUI maxDec
 Maximum decrease between two adjacent values.
 
TUI maxInc
 Maximum increase between two adjacent values.
 
TUI min
 Maximum value (when zig-zag encoded)
 
TUI minDec
 Minimum decrease between two adjacent values.
 
TUI minInc
 Minimum increase between two adjacent values.
 

Public Method Index:

 Array (const TIntegral &firstValue, const TIntegral &secondValue, size_t length)
 
 Array (const TIntegral *arrayStart, size_t length)
 
void calcMinMax ()
 
TUI get (size_t idx) const
 
size_t length () const
 
void set (size_t idx, TUI value)
 

Private Field Index:

size_t distance
 The distance in memory between two array values.
 
char * firstVal
 Pointer to the first array value.
 
size_t len
 The length of the array.
 

Type Definition Details:

◆ TUI

template<typename TIntegral>
using alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::TUI = typename std::make_unsigned<TIntegral>::type

The unsigned version of template type TIntegral.

Definition at line 73 of file ac.inl.

Field Details:

◆ distance

template<typename TIntegral>
size_t alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::distance
private

The distance in memory between two array values.

Definition at line 77 of file ac.inl.

◆ firstVal

template<typename TIntegral>
char* alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::firstVal
private

Pointer to the first array value.

Definition at line 76 of file ac.inl.

◆ len

template<typename TIntegral>
size_t alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::len
private

The length of the array.

Definition at line 78 of file ac.inl.

◆ max

template<typename TIntegral>
TUI alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::max

Maximum value (when zig-zag encoded)

Definition at line 82 of file ac.inl.

◆ maxDec

template<typename TIntegral>
TUI alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::maxDec

Maximum decrease between two adjacent values.

Definition at line 84 of file ac.inl.

◆ maxInc

template<typename TIntegral>
TUI alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::maxInc

Maximum increase between two adjacent values.

Definition at line 83 of file ac.inl.

◆ min

template<typename TIntegral>
TUI alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::min

Maximum value (when zig-zag encoded)

Definition at line 81 of file ac.inl.

◆ minDec

template<typename TIntegral>
TUI alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::minDec

Minimum decrease between two adjacent values.

Definition at line 86 of file ac.inl.

◆ minInc

template<typename TIntegral>
TUI alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::minInc

Minimum increase between two adjacent values.

Definition at line 85 of file ac.inl.

Constructor(s) / Destructor Details:

◆ Array() [1/2]

template<typename TIntegral>
alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::Array ( const TIntegral * arrayStart,
size_t length )
inline

This constructor may (and must only) be used when the data is stored in simple arrays, hence when the data is not nested in an array of structs.

Parameters
arrayStartPointer to the first value of the array.
lengthThe length of the array

Definition at line 96 of file ac.inl.

Here is the call graph for this function:

◆ Array() [2/2]

template<typename TIntegral>
alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::Array ( const TIntegral & firstValue,
const TIntegral & secondValue,
size_t length )
inline

This constructor takes the first and the second array value as pointers. The second is used to "assume" (!) the distance in memory between each value.

Attention
If the assumption of such basic memory layout is wrong, array values have to be copied to a temporary memory that satisfies this rule.
Parameters
firstValuePointer to the first value of the array.
secondValuePointer to the second value of the array
lengthThe length of the array

Definition at line 116 of file ac.inl.

Here is the call graph for this function:

Method Details:

◆ calcMinMax()

template<typename TIntegral>
void alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::calcMinMax ( )
inline

Loops over the data and stores minimum and maximum values as well as minimum and maximum value distances.

Definition at line 186 of file ac.inl.

Here is the call graph for this function:

◆ get()

template<typename TIntegral>
TUI alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::get ( size_t idx) const
inline

Returns the value at the given index as an unsigned integer value (for arrays of signed values, zig-zag encoding is performed)

Parameters
idxThe index of the value in the array to retrieve.
Returns
An unsigned representation of the value at the given index.

Definition at line 140 of file ac.inl.

◆ length()

template<typename TIntegral>
size_t alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::length ( ) const
inline

Returns the constant array length, given on construction.

Returns
The length of the array to compress/decompress

Definition at line 131 of file ac.inl.

◆ set()

template<typename TIntegral>
void alib::bitbuffer::ac_v1::ArrayCompressor::Array< TIntegral >::set ( size_t idx,
TUI value )
inline

Writes the given value at the given idx as an unsigned integer value (for arrays of signed values, zig-zag encoding is performed)

Parameters
idxThe index of the value in the array to set.
valueThe value to set.

Definition at line 158 of file ac.inl.


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