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 uint_pair 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 53 of file uint_types.hpp.
#include <uint_types.hpp>
Public Types | |
using | high_type = HighType |
higher part type, currently either 8-bit or 16-bit More... | |
using | low_type = uint32_t |
lower part type, always 32-bit More... | |
Public Member Functions | |
uint_pair () | |
empty constructor, does not even initialize to zero! More... | |
uint_pair (const low_type &l, const high_type &h) | |
construct unit pair from lower and higher parts. More... | |
uint_pair (const uint32_t &a) | |
implicit conversion from a simple 32-bit unsigned integer More... | |
uint_pair (const int32_t &a) | |
implicit conversion from a simple 32-bit signed integer More... | |
uint_pair (const uint64_t &a) | |
implicit conversion from an uint64_t (unsigned long long) More... | |
operator uint64_t () const | |
implicit cast to an unsigned long long More... | |
bool | operator!= (const uint_pair &b) const |
inequality checking operator More... | |
uint_pair & | operator++ () |
prefix increment operator (directly manipulates the integer parts) More... | |
uint_pair & | operator+= (const uint_pair &b) |
addition operator (uses 64-bit arithmetic) More... | |
uint_pair & | operator-- () |
prefix decrement operator (directly manipulates the integer parts) More... | |
bool | operator< (const uint_pair &b) const |
less-than comparison operator More... | |
bool | operator<= (const uint_pair &b) const |
less-or-equal comparison operator More... | |
bool | operator== (const uint_pair &b) const |
equality checking operator More... | |
bool | operator> (const uint_pair &b) const |
greater comparison operator More... | |
bool | operator>= (const uint_pair &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_t (unsigned long long) More... | |
Static Public Member Functions | |
static uint_pair | max () |
return an uint_pair instance containing the largest value possible More... | |
static uint_pair | min () |
return an uint_pair instance containing the smallest value possible More... | |
Static Public Attributes | |
static const size_t | bytes = sizeof(low_type) + sizeof(high_type) |
number of bytes in uint_pair More... | |
static const size_t | digits = low_bits + high_bits |
number of binary digits (bits) in uint_pair More... | |
Static Private Member Functions | |
static high_type | high_max () |
return highest value storable in higher part, also used as a mask. More... | |
static low_type | low_max () |
return highest value storable in lower part, also used as a mask. More... | |
Private Attributes | |
high_type | high |
member containing higher significant integer value More... | |
low_type | low |
member containing lower significant integer value More... | |
Static Private Attributes | |
static const size_t | high_bits = 8 * sizeof(high_type) |
number of bits in the higher integer part, used a bit shift value. More... | |
static const size_t | low_bits = 8 * sizeof(low_type) |
number of bits in the lower integer part, used a bit shift value. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const uint_pair &a) |
make a uint_pair outputtable via iostreams, using unsigned long long. More... | |
using high_type = HighType |
higher part type, currently either 8-bit or 16-bit
Definition at line 59 of file uint_types.hpp.
using low_type = uint32_t |
lower part type, always 32-bit
Definition at line 57 of file uint_types.hpp.
|
inline |
empty constructor, does not even initialize to zero!
Definition at line 93 of file uint_types.hpp.
Referenced by uint_pair< HighType >::max(), and uint_pair< HighType >::min().
construct unit pair from lower and higher parts.
Definition at line 114 of file uint_types.hpp.
|
inline |
implicit conversion from a simple 32-bit unsigned integer
Definition at line 119 of file uint_types.hpp.
|
inline |
implicit conversion from a simple 32-bit signed integer
Definition at line 124 of file uint_types.hpp.
|
inline |
implicit conversion from an uint64_t (unsigned long long)
Definition at line 134 of file uint_types.hpp.
|
inlinestaticprivate |
return highest value storable in higher part, also used as a mask.
Definition at line 77 of file uint_types.hpp.
Referenced by operator!=().
|
inlinestaticprivate |
return highest value storable in lower part, also used as a mask.
Definition at line 68 of file uint_types.hpp.
Referenced by operator!=(), uint_pair< HighType >::operator++(), and uint_pair< HighType >::operator--().
|
inlinestatic |
return an uint_pair instance containing the largest value possible
Definition at line 241 of file uint_types.hpp.
References foxxll::__attribute__(), max(), and uint_pair< HighType >::uint_pair().
Referenced by numeric_limits< foxxll::uint_pair< HighType > >::max().
|
inlinestatic |
return an uint_pair instance containing the smallest value possible
Definition at line 232 of file uint_types.hpp.
References min(), and uint_pair< HighType >::uint_pair().
Referenced by numeric_limits< foxxll::uint_pair< HighType > >::lowest(), and numeric_limits< foxxll::uint_pair< HighType > >::min().
|
inline |
implicit cast to an unsigned long long
Definition at line 149 of file uint_types.hpp.
References uint_pair< HighType >::ull().
|
inline |
inequality checking operator
Definition at line 196 of file uint_types.hpp.
|
inline |
prefix increment operator (directly manipulates the integer parts)
Definition at line 161 of file uint_types.hpp.
References uint_pair< HighType >::high, uint_pair< HighType >::low_max(), and TLX_UNLIKELY.
addition operator (uses 64-bit arithmetic)
Definition at line 181 of file uint_types.hpp.
|
inline |
prefix decrement operator (directly manipulates the integer parts)
Definition at line 171 of file uint_types.hpp.
References uint_pair< HighType >::high, uint_pair< HighType >::low_max(), and TLX_UNLIKELY.
|
inline |
less-than comparison operator
Definition at line 202 of file uint_types.hpp.
|
inline |
less-or-equal comparison operator
Definition at line 208 of file uint_types.hpp.
|
inline |
equality checking operator
Definition at line 190 of file uint_types.hpp.
|
inline |
greater comparison operator
Definition at line 214 of file uint_types.hpp.
|
inline |
greater-or-equal comparison operator
Definition at line 220 of file uint_types.hpp.
|
inline |
return the number as a uint64_t
Definition at line 155 of file uint_types.hpp.
|
inline |
return the number as an uint64_t (unsigned long long)
Definition at line 143 of file uint_types.hpp.
References uint_pair< HighType >::high.
Referenced by uint_pair< HighType >::operator uint64_t().
|
friend |
make a uint_pair outputtable via iostreams, using unsigned long long.
Definition at line 226 of file uint_types.hpp.
number of bytes in uint_pair
Definition at line 90 of file uint_types.hpp.
number of binary digits (bits) in uint_pair
Definition at line 87 of file uint_types.hpp.
|
private |
member containing higher significant integer value
Definition at line 65 of file uint_types.hpp.
Referenced by uint_pair< HighType >::operator++(), operator--(), uint_pair< HighType >::operator--(), and uint_pair< HighType >::ull().
|
staticprivate |
number of bits in the higher integer part, used a bit shift value.
Definition at line 83 of file uint_types.hpp.
|
private |
member containing lower significant integer value
Definition at line 63 of file uint_types.hpp.
Referenced by operator!=().
|
staticprivate |
number of bits in the lower integer part, used a bit shift value.
Definition at line 74 of file uint_types.hpp.
Referenced by operator!=().