STXXL  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::uint_pair< HighType > Class Template Reference

Detailed Description

template<typename HighType>
class stxxl::uint_pair< HighType >

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

Public Types

typedef HighType high_type
 higher part type, currently either 8-bit or 16-bit More...
 
typedef uint32 low_type
 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 uint_pair &a)
 copy constructor More...
 
 uint_pair (const uint32 &a)
 const from a simple 32-bit unsigned integer More...
 
 uint_pair (const int32 &a)
 const from a simple 32-bit signed integer More...
 
 uint_pair (const uint64 &a)
 construct from an uint64 (unsigned long long) More...
 
 operator uint64 () const
 implicit cast to an unsigned long long More...
 
bool operator!= (const uint_pair &b) const
 inequality checking operator More...
 
uint_pairoperator++ ()
 prefix increment operator (directly manipulates the integer parts) More...
 
uint_pairoperator+= (const uint_pair &b)
 addition operator (uses 64-bit arithmetic) More...
 
uint_pairoperator-- ()
 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 u64 () const
 return the number as a uint64 More...
 
uint64 ull () const
 return the number as an uint64 (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 int bytes = sizeof(low_type) + sizeof(high_type)
 number of bytes in uint_pair More...
 
static const int 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 int high_bits = 8 * sizeof(high_type)
 number of bits in the higher integer part, used a bit shift value. More...
 
static const int 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...
 

Member Typedef Documentation

template<typename HighType >
typedef HighType stxxl::uint_pair< HighType >::high_type

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

Definition at line 59 of file uint_types.h.

template<typename HighType >
typedef uint32 stxxl::uint_pair< HighType >::low_type

lower part type, always 32-bit

Definition at line 57 of file uint_types.h.

Constructor & Destructor Documentation

template<typename HighType >
stxxl::uint_pair< HighType >::uint_pair ( )
inline

empty constructor, does not even initialize to zero!

Definition at line 93 of file uint_types.h.

template<typename HighType >
stxxl::uint_pair< HighType >::uint_pair ( const low_type l,
const high_type h 
)
inline

construct unit pair from lower and higher parts.

Definition at line 105 of file uint_types.h.

template<typename HighType >
stxxl::uint_pair< HighType >::uint_pair ( const uint_pair< HighType > &  a)
inline

copy constructor

Definition at line 110 of file uint_types.h.

template<typename HighType >
stxxl::uint_pair< HighType >::uint_pair ( const uint32 a)
inline

const from a simple 32-bit unsigned integer

Definition at line 115 of file uint_types.h.

template<typename HighType >
stxxl::uint_pair< HighType >::uint_pair ( const int32 a)
inline

const from a simple 32-bit signed integer

Definition at line 120 of file uint_types.h.

template<typename HighType >
stxxl::uint_pair< HighType >::uint_pair ( const uint64 a)
inline

construct from an uint64 (unsigned long long)

Definition at line 130 of file uint_types.h.

References high_bits, and low_bits.

Member Function Documentation

template<typename HighType >
static high_type stxxl::uint_pair< HighType >::high_max ( )
inlinestaticprivate

return highest value storable in higher part, also used as a mask.

Definition at line 77 of file uint_types.h.

template<typename HighType >
static low_type stxxl::uint_pair< HighType >::low_max ( )
inlinestaticprivate

return highest value storable in lower part, also used as a mask.

Definition at line 68 of file uint_types.h.

template<typename HighType >
static uint_pair stxxl::uint_pair< HighType >::max ( )
inlinestatic

return an uint_pair instance containing the largest value possible

Definition at line 235 of file uint_types.h.

Referenced by std::numeric_limits< stxxl::uint_pair< HighType > >::max().

template<typename HighType >
static uint_pair stxxl::uint_pair< HighType >::min ( )
inlinestatic

return an uint_pair instance containing the smallest value possible

Definition at line 228 of file uint_types.h.

References min(), and uint_pair().

Referenced by std::numeric_limits< stxxl::uint_pair< HighType > >::min().

template<typename HighType >
stxxl::uint_pair< HighType >::operator uint64 ( ) const
inline

implicit cast to an unsigned long long

Definition at line 145 of file uint_types.h.

References ull().

template<typename HighType >
bool stxxl::uint_pair< HighType >::operator!= ( const uint_pair< HighType > &  b) const
inline

inequality checking operator

Definition at line 192 of file uint_types.h.

References stxxl::uint_pair< HighType >::high, high, stxxl::uint_pair< HighType >::low, and low.

template<typename HighType >
uint_pair& stxxl::uint_pair< HighType >::operator++ ( )
inline

prefix increment operator (directly manipulates the integer parts)

Definition at line 157 of file uint_types.h.

References low, low_max(), and UNLIKELY.

template<typename HighType >
uint_pair& stxxl::uint_pair< HighType >::operator+= ( const uint_pair< HighType > &  b)
inline

addition operator (uses 64-bit arithmetic)

Definition at line 177 of file uint_types.h.

References stxxl::uint_pair< HighType >::high, high, high_max(), stxxl::uint_pair< HighType >::low, low, low_bits, and low_max().

template<typename HighType >
uint_pair& stxxl::uint_pair< HighType >::operator-- ( )
inline

prefix decrement operator (directly manipulates the integer parts)

Definition at line 167 of file uint_types.h.

References high, low, low_max(), and UNLIKELY.

template<typename HighType >
bool stxxl::uint_pair< HighType >::operator< ( const uint_pair< HighType > &  b) const
inline

less-than comparison operator

Definition at line 198 of file uint_types.h.

References stxxl::uint_pair< HighType >::high, high, stxxl::uint_pair< HighType >::low, and low.

template<typename HighType >
bool stxxl::uint_pair< HighType >::operator<= ( const uint_pair< HighType > &  b) const
inline

less-or-equal comparison operator

Definition at line 204 of file uint_types.h.

References stxxl::uint_pair< HighType >::high, high, stxxl::uint_pair< HighType >::low, and low.

template<typename HighType >
bool stxxl::uint_pair< HighType >::operator== ( const uint_pair< HighType > &  b) const
inline

equality checking operator

Definition at line 186 of file uint_types.h.

template<typename HighType >
bool stxxl::uint_pair< HighType >::operator> ( const uint_pair< HighType > &  b) const
inline

greater comparison operator

Definition at line 210 of file uint_types.h.

References stxxl::uint_pair< HighType >::high, high, stxxl::uint_pair< HighType >::low, and low.

template<typename HighType >
bool stxxl::uint_pair< HighType >::operator>= ( const uint_pair< HighType > &  b) const
inline

greater-or-equal comparison operator

Definition at line 216 of file uint_types.h.

References stxxl::uint_pair< HighType >::high, high, stxxl::uint_pair< HighType >::low, and low.

template<typename HighType >
uint64 stxxl::uint_pair< HighType >::u64 ( ) const
inline

return the number as a uint64

Definition at line 151 of file uint_types.h.

References high, low, and low_bits.

template<typename HighType >
uint64 stxxl::uint_pair< HighType >::ull ( ) const
inline

return the number as an uint64 (unsigned long long)

Definition at line 139 of file uint_types.h.

Friends And Related Function Documentation

template<typename HighType >
std::ostream& operator<< ( std::ostream &  os,
const uint_pair< HighType > &  a 
)
friend

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

Definition at line 222 of file uint_types.h.

Member Data Documentation

template<typename HighType >
const int stxxl::uint_pair< HighType >::bytes = sizeof(low_type) + sizeof(high_type)
static

number of bytes in uint_pair

Definition at line 90 of file uint_types.h.

template<typename HighType >
const int stxxl::uint_pair< HighType >::digits = low_bits + high_bits
static

number of binary digits (bits) in uint_pair

Definition at line 87 of file uint_types.h.

template<typename HighType >
const int stxxl::uint_pair< HighType >::high_bits = 8 * sizeof(high_type)
staticprivate

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

Definition at line 83 of file uint_types.h.

template<typename HighType >
const int stxxl::uint_pair< HighType >::low_bits = 8 * sizeof(low_type)
staticprivate

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

Definition at line 74 of file uint_types.h.


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