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... | |
| T | operator+ (T val) |
| Update by a certain value. More... | |
| T | getVal () const |
| Get the value of the counter. More... | |
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.
| T | Should be large enough to hold arithmetic overflow. This class works with both signed and unsigned integer. |
| 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.
|
inline |
Get the value of the counter.
| T OmniSketch::Util::DynamicIntX< T >::operator+ | ( | T | val | ) |
Update by a certain value.
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].