ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Fields | Public Methods | Private Fields | List of all members
ArrayCompressor::Array< TIntegral > Class Template Reference

#include <ac.hpp>

Class Description

template<typename TIntegral>
class aworx::lib::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 casted 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, wich 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 150 of file ac.hpp.

Public Types

using TUI = typename std::make_unsigned< TIntegral >::type
 

Public Fields

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 Methods

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

Private Fields

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.
 

Member Typedef Documentation

◆ TUI

using TUI = typename std::make_unsigned<TIntegral>::type

The unsigned version of template type TIntegral.

Definition at line 154 of file ac.hpp.

Constructor & Destructor Documentation

◆ Array() [1/2]

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 180 of file ac.hpp.

◆ Array() [2/2]

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 202 of file ac.hpp.

Member Function Documentation

◆ calcMinMax()

void calcMinMax ( )
inline

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

Definition at line 286 of file ac.hpp.

Here is the call graph for this function:

◆ get()

ALIB_FORCE_INLINE TUI 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 231 of file ac.hpp.

◆ length()

ALIB_FORCE_INLINE size_t length ( ) const
inline

Returns the constant array length, given on construction.

Returns
The length of the array to compress/decompress

Definition at line 220 of file ac.hpp.

◆ set()

ALIB_FORCE_INLINE void 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 254 of file ac.hpp.


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