Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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

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.

Constructor & Destructor Documentation

UIntPair ( )
default

empty constructor, does not even initialize to zero!

Referenced by UIntPair< High_ >::max(), UIntPair< High_ >::min(), UIntPair< High_ >::operator+(), and UIntPair< High_ >::operator-().

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.

UIntPair ( const UIntPair< High_ > &  )
default

copy constructor

UIntPair ( UIntPair< High_ > &&  )
default

move constructor

UIntPair ( const uint32_t &  a)
inline

const from a simple 32-bit unsigned integer

Definition at line 105 of file uint_types.hpp.

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_, UIntPair< High_ >::high_max(), and UIntPair< High_ >::low_.

UIntPair ( const unsigned long long &  a)
inline

construct from an 64-bit unsigned integer

Definition at line 118 of file uint_types.hpp.

References UIntPair< High_ >::high_bits, and UIntPair< High_ >::low_bits.

UIntPair ( const unsigned long &  a)
inline

construct from an 64-bit signed integer

Definition at line 126 of file uint_types.hpp.

UIntPair ( const int64_t &  a)
inline

construct from an 64-bit signed integer

Definition at line 130 of file uint_types.hpp.

Member Function Documentation

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 thrill::common::max().

Referenced by UIntPair< High_ >::operator+(), UIntPair< High_ >::operator+=(), UIntPair< High_ >::operator-(), UIntPair< High_ >::operator-=(), and UIntPair< High_ >::UIntPair().

static unsigned low_max ( )
inlinestaticprivate
static UIntPair max ( )
inlinestatic

return an UIntPair instance containing the largest value possible

Definition at line 250 of file uint_types.hpp.

References thrill::common::max(), and UIntPair< High_ >::UIntPair().

static UIntPair min ( )
inlinestatic

return an UIntPair instance containing the smallest value possible

Definition at line 244 of file uint_types.hpp.

References thrill::common::min(), and UIntPair< High_ >::UIntPair().

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

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_.

UIntPair operator+ ( const UIntPair< High_ > &  b) const
inline
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.

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_, UIntPair< High_ >::low_bits, and UIntPair< High_ >::low_max().

UIntPair operator- ( const UIntPair< High_ > &  b) const
inline
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.

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_, UIntPair< High_ >::low_bits, and UIntPair< High_ >::low_max().

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_.

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

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_.

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

copy assignment operator

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

move assignment 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_.

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_.

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_.

uint64_t u64 ( ) const
inline

return the number as a uint64_t

Definition at line 149 of file uint_types.hpp.

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

uint64_t ull ( ) const
inline

return the number as an uint64 (unsigned long long)

Definition at line 139 of file uint_types.hpp.

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

Referenced by UIntPair< High_ >::operator uint64_t(), and UIntPair< High_ >::operator<().

Friends And Related Function Documentation

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

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

number of bytes in UIntPair

Definition at line 86 of file uint_types.hpp.

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.

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.

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

constexpr size_t low_bits = 8 * sizeof(Low)
staticprivate

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