Thrill  0.1
UIntPair< High_ > Class Template Reference

Detailed Description

template<typename High_>
class thrill::common::UIntPair< High_ >

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...
 
UIntPairoperator++ ()
 prefix increment operator (directly manipulates the integer parts) More...
 
UIntPairoperator+= (const UIntPair &b)
 addition operator (uses 64-bit arithmetic) More...
 
UIntPair operator- (const UIntPair &b) const
 subtraction operator (uses 64-bit arithmetic) More...
 
UIntPairoperator-- ()
 prefix decrement operator (directly manipulates the integer parts) More...
 
UIntPairoperator-= (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...
 
UIntPairoperator= (const UIntPair &)=default
 copy assignment operator More...
 
UIntPairoperator= (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...
 

Member Typedef Documentation

◆ High

using High = High_

higher part type, currently either 8-bit or 16-bit

Definition at line 57 of file uint_types.hpp.

◆ Low

using Low = uint32_t

lower part type, always 32-bit

Definition at line 55 of file uint_types.hpp.

Constructor & Destructor Documentation

◆ UIntPair() [1/9]

◆ UIntPair() [2/9]

UIntPair ( const Low l,
const High h 
)
inline

construct unit pair from lower and higher parts.

Definition at line 96 of file uint_types.hpp.

References UIntPair< High_ >::UIntPair().

◆ UIntPair() [3/9]

UIntPair ( const UIntPair< High_ > &  )
default

copy constructor

◆ UIntPair() [4/9]

UIntPair ( UIntPair< High_ > &&  )
default

move constructor

◆ UIntPair() [5/9]

UIntPair ( const uint32_t &  a)
inline

const from a simple 32-bit unsigned integer

Definition at line 105 of file uint_types.hpp.

◆ UIntPair() [6/9]

UIntPair ( const int32_t &  a)
inline

const from a simple 32-bit signed integer

Definition at line 109 of file uint_types.hpp.

References UIntPair< High_ >::high_max().

◆ UIntPair() [7/9]

UIntPair ( const unsigned long long &  a)
inline

construct from an 64-bit unsigned integer

Definition at line 118 of file uint_types.hpp.

◆ UIntPair() [8/9]

UIntPair ( const unsigned long &  a)
inline

construct from an 64-bit signed integer

Definition at line 126 of file uint_types.hpp.

◆ UIntPair() [9/9]

UIntPair ( const int64_t &  a)
inline

construct from an 64-bit signed integer

Definition at line 130 of file uint_types.hpp.

References UIntPair< High_ >::operator=().

Member Function Documentation

◆ high_max()

static unsigned high_max ( )
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().

◆ low_max()

static unsigned low_max ( )
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-=().

◆ max()

static UIntPair max ( )
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().

◆ min()

static UIntPair min ( )
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().

◆ operator uint64_t()

operator uint64_t ( ) const
inline

implicit cast to an unsigned long long

Definition at line 144 of file uint_types.hpp.

References UIntPair< High_ >::ull().

◆ operator!=()

bool operator!= ( const UIntPair< High_ > &  b) const
inline

inequality checking operator

Definition at line 209 of file uint_types.hpp.

References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.

◆ operator+()

UIntPair operator+ ( const UIntPair< High_ > &  b) const
inline

◆ operator++()

UIntPair& operator++ ( )
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.

◆ operator+=()

UIntPair& operator+= ( const UIntPair< High_ > &  b)
inline

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().

◆ operator-()

UIntPair operator- ( const UIntPair< High_ > &  b) const
inline

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().

◆ operator--()

UIntPair& operator-- ( )
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.

◆ operator-=()

UIntPair& operator-= ( const UIntPair< High_ > &  b)
inline

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().

◆ operator<() [1/2]

bool operator< ( const UIntPair< High_ > &  b) const
inline

less-than comparison operator

Definition at line 214 of file uint_types.hpp.

References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.

◆ operator<() [2/2]

bool operator< ( const uint64_t &  b) const
inline

less-than comparison operator

Definition at line 219 of file uint_types.hpp.

References UIntPair< High_ >::ull().

◆ operator<=()

bool operator<= ( const UIntPair< High_ > &  b) const
inline

less-or-equal comparison operator

Definition at line 224 of file uint_types.hpp.

References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.

◆ operator=() [1/2]

UIntPair& operator= ( const UIntPair< High_ > &  )
default

copy assignment operator

Referenced by UIntPair< High_ >::UIntPair().

◆ operator=() [2/2]

UIntPair& operator= ( UIntPair< High_ > &&  )
default

move assignment operator

◆ operator==()

bool operator== ( const UIntPair< High_ > &  b) const
inline

equality checking operator

Definition at line 204 of file uint_types.hpp.

References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.

◆ operator>()

bool operator> ( const UIntPair< High_ > &  b) const
inline

greater comparison operator

Definition at line 229 of file uint_types.hpp.

References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.

◆ operator>=()

bool operator>= ( const UIntPair< High_ > &  b) const
inline

greater-or-equal comparison operator

Definition at line 234 of file uint_types.hpp.

References UIntPair< High_ >::high_, and UIntPair< High_ >::low_.

◆ u64()

uint64_t u64 ( ) const
inline

return the number as a uint64_t

Definition at line 149 of file uint_types.hpp.

◆ ull()

uint64_t ull ( ) const
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<().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const UIntPair< High_ > &  a 
)
friend

make a UIntPair outputtable via iostreams, using unsigned long long.

Definition at line 239 of file uint_types.hpp.

Member Data Documentation

◆ bytes

constexpr size_t bytes = sizeof(Low) + sizeof(High)
static

number of bytes in UIntPair

Definition at line 86 of file uint_types.hpp.

◆ digits

constexpr size_t digits = low_bits + high_bits
static

number of binary digits (bits) in UIntPair

Definition at line 83 of file uint_types.hpp.

◆ high_

◆ high_bits

constexpr size_t high_bits = 8 * sizeof(High)
staticprivate

number of bits in the higher integer part, used a bit shift value.

Definition at line 79 of file uint_types.hpp.

◆ low_

◆ low_bits

constexpr size_t low_bits = 8 * sizeof(Low)
staticprivate

number of bits in the lower integer part, used a bit shift value.

Definition at line 71 of file uint_types.hpp.


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