OmniSketch  0.1
Oh my sketch!
OmniSketch::Util::DynamicIntX< T > Class Template Reference

Integer of any fixed length. More...

#include <utils.h>

Public Member Functions

 DynamicIntX (size_t bits)
 Construct by specifying the length of the integer. More...
 
operator+ (T val)
 Update by a certain value. More...
 
getVal () const
 Get the value of the counter. More...
 

Detailed Description

template<typename T>
class OmniSketch::Util::DynamicIntX< T >

Integer of any fixed length.

Length of integer is specified at run-time. The content of the counter is always interpreted as a non-negative value.

Template Parameters
TShould be large enough to hold arithmetic overflow. This class works with both signed and unsigned integer.

Constructor & Destructor Documentation

◆ DynamicIntX()

template<typename T >
OmniSketch::Util::DynamicIntX< T >::DynamicIntX ( size_t  bits)

Construct by specifying the length of the integer.

In bits. Must be in (0, 8 * sizeof(T) - 1), or an exception would be thrown.

Member Function Documentation

◆ getVal()

template<typename T >
T OmniSketch::Util::DynamicIntX< T >::getVal ( ) const
inline

Get the value of the counter.

◆ operator+()

template<typename T >
T OmniSketch::Util::DynamicIntX< T >::operator+ ( val)

Update by a certain value.

Note
If T is signed and val is negative, make sure val is within [-(2^n - 1), 2^n - 1], where n = 8 * sizeof(T) - 2. (This is a technical requirement due to the correct interpretation of overflow) For example, the range when T = int32_t is [-1073741823, 1073741823].
Returns
the overflowed value