Thrill
0.1
|
Construct an 40-bit or 48-bit unsigned integer stored in five or six bytes.
The purpose of this class is to provide integers with smaller data storage footprints when more than 32-bit, but less than 64-bit indexes are needed. This is commonly the case for storing file offsets and indexes. Here smaller types currently suffice for files < 1 TiB or < 16 TiB.
The class combines a 32-bit integer with a HighType (either 8-bit or 16-bit) to get a larger type. Only unsigned values are supported, which fits the general application of file offsets.
Calculation in UIntPair are generally done by transforming everything to 64-bit data type, so that 64-bit register arithmetic can be used. The exception here is increment and decrement, which is done directly on the lower/higher part. Not all arithmetic operations are supported, patches welcome if you really need the operations.
Definition at line 51 of file uint_types.hpp.
#include <uint_types.hpp>
Public Types | |
using | High = High_ |
higher part type, currently either 8-bit or 16-bit More... | |
using | Low = uint32_t |
lower part type, always 32-bit More... | |
Public Member Functions | |
UIntPair ()=default | |
empty constructor, does not even initialize to zero! More... | |
UIntPair (const Low &l, const High &h) | |
construct unit pair from lower and higher parts. More... | |
UIntPair (const UIntPair &)=default | |
copy constructor More... | |
UIntPair (UIntPair &&)=default | |
move constructor More... | |
UIntPair (const uint32_t &a) | |
const from a simple 32-bit unsigned integer More... | |
UIntPair (const int32_t &a) | |
const from a simple 32-bit signed integer More... | |
UIntPair (const unsigned long long &a) | |
construct from an 64-bit unsigned integer More... | |
UIntPair (const unsigned long &a) | |
construct from an 64-bit signed integer More... | |
UIntPair (const int64_t &a) | |
construct from an 64-bit signed integer More... | |
operator uint64_t () const | |
implicit cast to an unsigned long long More... | |
bool | operator!= (const UIntPair &b) const |
inequality checking operator More... | |
UIntPair | operator+ (const UIntPair &b) const |
addition operator (uses 64-bit arithmetic) More... | |
UIntPair & | operator++ () |
prefix increment operator (directly manipulates the integer parts) More... | |
UIntPair & | operator+= (const UIntPair &b) |
addition operator (uses 64-bit arithmetic) More... | |
UIntPair | operator- (const UIntPair &b) const |
subtraction operator (uses 64-bit arithmetic) More... | |
UIntPair & | operator-- () |
prefix decrement operator (directly manipulates the integer parts) More... | |
UIntPair & | operator-= (const UIntPair &b) |
subtraction operator (uses 64-bit arithmetic) More... | |
bool | operator< (const UIntPair &b) const |
less-than comparison operator More... | |
bool | operator< (const uint64_t &b) const |
less-than comparison operator More... | |
bool | operator<= (const UIntPair &b) const |
less-or-equal comparison operator More... | |
UIntPair & | operator= (const UIntPair &)=default |
copy assignment operator More... | |
UIntPair & | operator= (UIntPair &&)=default |
move assignment operator More... | |
bool | operator== (const UIntPair &b) const |
equality checking operator More... | |
bool | operator> (const UIntPair &b) const |
greater comparison operator More... | |
bool | operator>= (const UIntPair &b) const |
greater-or-equal comparison operator More... | |
uint64_t | u64 () const |
return the number as a uint64_t More... | |
uint64_t | ull () const |
return the number as an uint64 (unsigned long long) More... | |
Static Public Member Functions | |
static UIntPair | max () |
return an UIntPair instance containing the largest value possible More... | |
static UIntPair | min () |
return an UIntPair instance containing the smallest value possible More... | |
Static Public Attributes | |
static constexpr size_t | bytes = sizeof(Low) + sizeof(High) |
number of bytes in UIntPair More... | |
static constexpr size_t | digits = low_bits + high_bits |
number of binary digits (bits) in UIntPair More... | |
Static Private Member Functions | |
static unsigned | high_max () |
return highest value storable in higher part, also used as a mask. More... | |
static unsigned | low_max () |
return highest value storable in lower part, also used as a mask. More... | |
Private Attributes | |
High | high_ |
member containing higher significant integer value More... | |
Low | low_ |
member containing lower significant integer value More... | |
Static Private Attributes | |
static constexpr size_t | high_bits = 8 * sizeof(High) |
number of bits in the higher integer part, used a bit shift value. More... | |
static constexpr size_t | low_bits = 8 * sizeof(Low) |
number of bits in the lower integer part, used a bit shift value. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const UIntPair &a) |
make a UIntPair outputtable via iostreams, using unsigned long long. More... | |
using High = High_ |
higher part type, currently either 8-bit or 16-bit
Definition at line 57 of file uint_types.hpp.
using Low = uint32_t |
lower part type, always 32-bit
Definition at line 55 of file uint_types.hpp.
|
default |
empty constructor, does not even initialize to zero!
Referenced by numeric_limits< thrill::common::UIntPair< HighType > >::epsilon(), UIntPair< High_ >::max(), UIntPair< High_ >::min(), UIntPair< High_ >::operator+(), UIntPair< High_ >::operator-(), numeric_limits< thrill::common::UIntPair< HighType > >::round_error(), and UIntPair< High_ >::UIntPair().
construct unit pair from lower and higher parts.
Definition at line 96 of file uint_types.hpp.
References UIntPair< High_ >::UIntPair().
|
inline |
const from a simple 32-bit unsigned integer
Definition at line 105 of file uint_types.hpp.
|
inline |
const from a simple 32-bit signed integer
Definition at line 109 of file uint_types.hpp.
References UIntPair< High_ >::high_max().
|
inline |
construct from an 64-bit unsigned integer
Definition at line 118 of file uint_types.hpp.
|
inline |
construct from an 64-bit signed integer
Definition at line 126 of file uint_types.hpp.
|
inline |
construct from an 64-bit signed integer
Definition at line 130 of file uint_types.hpp.
References UIntPair< High_ >::operator=().
|
inlinestaticprivate |
return highest value storable in higher part, also used as a mask.
Definition at line 74 of file uint_types.hpp.
References max().
Referenced by UIntPair< High_ >::operator+(), UIntPair< High_ >::operator+=(), UIntPair< High_ >::operator-(), UIntPair< High_ >::operator-=(), and UIntPair< High_ >::UIntPair().
|
inlinestaticprivate |
return highest value storable in lower part, also used as a mask.
Definition at line 66 of file uint_types.hpp.
References max().
Referenced by UIntPair< High_ >::operator+(), UIntPair< High_ >::operator++(), UIntPair< High_ >::operator+=(), UIntPair< High_ >::operator-(), UIntPair< High_ >::operator--(), and UIntPair< High_ >::operator-=().
|
inlinestatic |
return an UIntPair instance containing the largest value possible
Definition at line 250 of file uint_types.hpp.
References max(), thrill::common::TLX_ATTRIBUTE_PACKED, and UIntPair< High_ >::UIntPair().
Referenced by numeric_limits< thrill::common::UIntPair< HighType > >::max().
|
inlinestatic |
return an UIntPair instance containing the smallest value possible
Definition at line 244 of file uint_types.hpp.
References min(), and UIntPair< High_ >::UIntPair().
Referenced by numeric_limits< thrill::common::UIntPair< HighType > >::lowest(), and numeric_limits< thrill::common::UIntPair< HighType > >::min().
|
inline |
implicit cast to an unsigned long long
Definition at line 144 of file uint_types.hpp.
References UIntPair< High_ >::ull().
|
inline |
inequality checking operator
Definition at line 209 of file uint_types.hpp.
References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.
addition operator (uses 64-bit arithmetic)
Definition at line 180 of file uint_types.hpp.
References UIntPair< High_ >::high_, UIntPair< High_ >::high_max(), UIntPair< High_ >::low_, UIntPair< High_ >::low_max(), and UIntPair< High_ >::UIntPair().
|
inline |
prefix increment operator (directly manipulates the integer parts)
Definition at line 154 of file uint_types.hpp.
References UIntPair< High_ >::high_, UIntPair< High_ >::low_, UIntPair< High_ >::low_max(), and TLX_UNLIKELY.
addition operator (uses 64-bit arithmetic)
Definition at line 172 of file uint_types.hpp.
References UIntPair< High_ >::high_, UIntPair< High_ >::high_max(), UIntPair< High_ >::low_, and UIntPair< High_ >::low_max().
subtraction operator (uses 64-bit arithmetic)
Definition at line 196 of file uint_types.hpp.
References UIntPair< High_ >::high_, UIntPair< High_ >::high_max(), UIntPair< High_ >::low_, UIntPair< High_ >::low_max(), and UIntPair< High_ >::UIntPair().
|
inline |
prefix decrement operator (directly manipulates the integer parts)
Definition at line 163 of file uint_types.hpp.
References UIntPair< High_ >::high_, UIntPair< High_ >::low_, UIntPair< High_ >::low_max(), and TLX_UNLIKELY.
subtraction operator (uses 64-bit arithmetic)
Definition at line 188 of file uint_types.hpp.
References UIntPair< High_ >::high_, UIntPair< High_ >::high_max(), UIntPair< High_ >::low_, and UIntPair< High_ >::low_max().
|
inline |
less-than comparison operator
Definition at line 214 of file uint_types.hpp.
References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.
|
inline |
less-than comparison operator
Definition at line 219 of file uint_types.hpp.
References UIntPair< High_ >::ull().
|
inline |
less-or-equal comparison operator
Definition at line 224 of file uint_types.hpp.
References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.
copy assignment operator
Referenced by UIntPair< High_ >::UIntPair().
|
inline |
equality checking operator
Definition at line 204 of file uint_types.hpp.
References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.
|
inline |
greater comparison operator
Definition at line 229 of file uint_types.hpp.
References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.
|
inline |
greater-or-equal comparison operator
Definition at line 234 of file uint_types.hpp.
References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.
|
inline |
return the number as a uint64_t
Definition at line 149 of file uint_types.hpp.
|
inline |
return the number as an uint64 (unsigned long long)
Definition at line 139 of file uint_types.hpp.
Referenced by UIntPair< High_ >::operator uint64_t(), and UIntPair< High_ >::operator<().
|
friend |
make a UIntPair outputtable via iostreams, using unsigned long long.
Definition at line 239 of file uint_types.hpp.
number of bytes in UIntPair
Definition at line 86 of file uint_types.hpp.
number of binary digits (bits) in UIntPair
Definition at line 83 of file uint_types.hpp.
|
private |
member containing higher significant integer value
Definition at line 63 of file uint_types.hpp.
Referenced by UIntPair< High_ >::operator!=(), UIntPair< High_ >::operator+(), UIntPair< High_ >::operator++(), UIntPair< High_ >::operator+=(), UIntPair< High_ >::operator-(), UIntPair< High_ >::operator--(), UIntPair< High_ >::operator-=(), UIntPair< High_ >::operator<(), UIntPair< High_ >::operator<=(), UIntPair< High_ >::operator==(), UIntPair< High_ >::operator>(), and UIntPair< High_ >::operator>=().
|
staticprivate |
number of bits in the higher integer part, used a bit shift value.
Definition at line 79 of file uint_types.hpp.
|
private |
member containing lower significant integer value
Definition at line 61 of file uint_types.hpp.
Referenced by UIntPair< High_ >::operator!=(), UIntPair< High_ >::operator+(), UIntPair< High_ >::operator++(), UIntPair< High_ >::operator+=(), UIntPair< High_ >::operator-(), UIntPair< High_ >::operator--(), UIntPair< High_ >::operator-=(), UIntPair< High_ >::operator<(), UIntPair< High_ >::operator<=(), UIntPair< High_ >::operator==(), UIntPair< High_ >::operator>(), and UIntPair< High_ >::operator>=().
|
staticprivate |
number of bits in the lower integer part, used a bit shift value.
Definition at line 71 of file uint_types.hpp.