ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
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 83 of file ac.hpp.

#include <ac.hpp>

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 ()
 
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 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 TUI = typename std::make_unsigned<TIntegral>::type

The unsigned version of template type TIntegral.

Definition at line 87 of file ac.hpp.

Field Details:

◆ distance

template<typename TIntegral >
size_t distance
private

The distance in memory between two array values.

Definition at line 91 of file ac.hpp.

◆ firstVal

template<typename TIntegral >
char* firstVal
private

Pointer to the first array value.

Definition at line 90 of file ac.hpp.

◆ len

template<typename TIntegral >
size_t len
private

The length of the array.

Definition at line 92 of file ac.hpp.

◆ max

template<typename TIntegral >
TUI max

Maximum value (when zig-zag encoded)

Definition at line 96 of file ac.hpp.

◆ maxDec

template<typename TIntegral >
TUI maxDec

Maximum decrease between two adjacent values.

Definition at line 98 of file ac.hpp.

◆ maxInc

template<typename TIntegral >
TUI maxInc

Maximum increase between two adjacent values.

Definition at line 97 of file ac.hpp.

◆ min

template<typename TIntegral >
TUI min

Maximum value (when zig-zag encoded)

Definition at line 95 of file ac.hpp.

◆ minDec

template<typename TIntegral >
TUI minDec

Minimum decrease between two adjacent values.

Definition at line 100 of file ac.hpp.

◆ minInc

template<typename TIntegral >
TUI minInc

Minimum increase between two adjacent values.

Definition at line 99 of file ac.hpp.

Constructor(s) / Destructor Details:

◆ Array() [1/2]

template<typename 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 111 of file ac.hpp.

◆ Array() [2/2]

template<typename 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 131 of file ac.hpp.

Method Details:

◆ calcMinMax()

template<typename TIntegral >
void calcMinMax ( )
inline

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

Definition at line 207 of file ac.hpp.

Here is the call graph for this function:

◆ get()

template<typename TIntegral >
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 156 of file ac.hpp.

◆ length()

template<typename TIntegral >
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 147 of file ac.hpp.

◆ set()

template<typename TIntegral >
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 177 of file ac.hpp.


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