Ocean
Ocean::Utilities Class Reference

This class implements basic utility functions. More...

Public Member Functions

template<>
float divideBy2 (const float &value)
 
template<>
double divideBy2 (const double &value)
 

Static Public Member Functions

static std::vector< std::string > separateValues (const std::string &values, const char delimiter=',', const bool removeQuotes=true, const bool trim=true)
 Separates a set of given values. More...
 
template<typename T >
static void sortLowestToFront2 (T &value0, T &value1)
 Sorts two values so that the lowest value will finally be the first value. More...
 
template<typename T >
static void sortLowestToFront3 (T &value0, T &value1, T &value2)
 Sorts three values so that the lowest value will finally be the first value. More...
 
template<typename T , typename TData >
static void sortLowestToFront2 (T &value0, T &value1, TData &data0, TData &data1)
 Sorts two values so that the lowest value will finally be the first value. More...
 
template<typename T , typename TData >
static void sortLowestToFront3 (T &value0, T &value1, T &value2, TData &data0, TData &data1, TData &data2)
 Sorts three values so that the lowest value will finally be the first value. More...
 
template<typename T >
static void sortHighestToFront2 (T &value0, T &value1)
 Sorts two values so that the highest value will finally be the first value. More...
 
template<typename T >
static void sortHighestToFront3 (T &value0, T &value1, T &value2)
 Sorts three values so that the highest value will finally be the first value. More...
 
template<typename T , typename TData >
static void sortHighestToFront2 (T &value0, T &value1, TData &data0, TData &data1)
 Sorts two values so that the highest value will finally be the first value. More...
 
template<typename T , typename TData >
static void sortHighestToFront3 (T &value0, T &value1, T &value2, TData &data0, TData &data1, TData &data2)
 Sorts three values so that the highest value will finally be the first value. More...
 
template<typename T >
static unsigned int lowestValue (const T &value0, const T &value1, const T &value2)
 Returns the index of the lowest value, if two or more values have the lowest value the smallest index of the values will be returned. More...
 
template<typename T >
static unsigned int highestValue (const T &value0, const T &value1, const T &value2)
 Returns the index of the highest value, if two or more values have the highest value the smallest index of the values will be returned. More...
 
template<typename T1 , typename T2 >
static bool sortPairFirst (const std::pair< T1, T2 > &firstPair, const std::pair< T1, T2 > &secondPair)
 Compares two pair objects and returns whether the first value of the first pair is lesser than the first value of the second pair. More...
 
template<typename T >
static bool sortPairFirst (const T &firstPair, const T &secondPair)
 Compares two pair objects and returns whether the first value of the first pair is lesser than the first value of the second pair. More...
 
template<typename T1 , typename T2 >
static bool sortPairSecond (const std::pair< T1, T2 > &firstPair, const std::pair< T1, T2 > &secondPair)
 Compares two pair objects and returns whether the second value of the first pair is lesser than the second value of the second pair. More...
 
template<typename T >
static bool sortPairSecond (const T &firstPair, const T &secondPair)
 Compares two pair objects and returns whether the second value of the first pair is lesser than the second value of the second pair. More...
 
template<typename T >
static T divideBy2 (const T &value)
 This function divides a given value by two. More...
 
static unsigned char divideBy255 (const unsigned int value)
 This function applies a fast division by 255 for unsigned integer values. More...
 
static bool isPowerOfTwo (const unsigned int value)
 Returns whether a given value is a power of two. More...
 
static unsigned int smallestPowerOfTwo (const unsigned int value)
 Returns the smallest power of two value that is equal or larger than a given value. More...
 
static void multiply64 (const uint64_t left, const uint64_t right, uint64_t &resultHigh, uint64_t &resultLow)
 Multiplies the specified 64 bit integers and stores the 128 bit integer result in resultHigh (64 most significant bits) and resultLow (64 least significant bits). More...
 
static int compareProducts (const uint64_t leftFactor1, const uint64_t leftFactor2, const uint64_t rightFactor1, const uint64_t rightFactor2)
 Compares the product specified by the first two factors with the product specified by the last two factors. More...
 

Detailed Description

This class implements basic utility functions.

Member Function Documentation

◆ compareProducts()

int Ocean::Utilities::compareProducts ( const uint64_t  leftFactor1,
const uint64_t  leftFactor2,
const uint64_t  rightFactor1,
const uint64_t  rightFactor2 
)
inlinestatic

Compares the product specified by the first two factors with the product specified by the last two factors.

Parameters
leftFactor1First factor of left operand
leftFactor2Second factor of left operand
rightFactor1First factor of right operand
rightFactor2Second factor of right operand
Returns
1 if the left product is greater than the right product, -1 if it is less and 0 if both are equal.

◆ divideBy2() [1/3]

template<>
double Ocean::Utilities::divideBy2 ( const double &  value)
inline

◆ divideBy2() [2/3]

template<>
float Ocean::Utilities::divideBy2 ( const float &  value)
inline

◆ divideBy2() [3/3]

template<typename T >
T Ocean::Utilities::divideBy2 ( const T &  value)
inlinestatic

This function divides a given value by two.

Integer values are divided by two (bit shifting is no applied), floating point values are multiplied by 0.5.

Parameters
valueThe value to be divided
Template Parameters
TThe data type of the value
Returns
The resulting value

◆ divideBy255()

unsigned char Ocean::Utilities::divideBy255 ( const unsigned int  value)
inlinestatic

This function applies a fast division by 255 for unsigned integer values.

Parameters
valueThe value that will be divided by 255, with range [0, 65534]
Returns
Divided unsigned integer value

◆ highestValue()

template<typename T >
unsigned int Ocean::Utilities::highestValue ( const T &  value0,
const T &  value1,
const T &  value2 
)
static

Returns the index of the highest value, if two or more values have the highest value the smallest index of the values will be returned.

Parameters
value0The first value
value1The second value
value2The third value
Returns
The resulting index with range [0, 2]

◆ isPowerOfTwo()

bool Ocean::Utilities::isPowerOfTwo ( const unsigned int  value)
inlinestatic

Returns whether a given value is a power of two.

Zero is not a power of two value.

Parameters
valueThe value to be checked, with range [0, infinity)
Returns
True, if so

◆ lowestValue()

template<typename T >
unsigned int Ocean::Utilities::lowestValue ( const T &  value0,
const T &  value1,
const T &  value2 
)
static

Returns the index of the lowest value, if two or more values have the lowest value the smallest index of the values will be returned.

Parameters
value0The first value
value1The second value
value2The third value
Returns
The resulting index with range [0, 2]

◆ multiply64()

static void Ocean::Utilities::multiply64 ( const uint64_t  left,
const uint64_t  right,
uint64_t &  resultHigh,
uint64_t &  resultLow 
)
static

Multiplies the specified 64 bit integers and stores the 128 bit integer result in resultHigh (64 most significant bits) and resultLow (64 least significant bits).

Parameters
leftThe left operand
rightThe right operand
resultHighReceives the 64 most significant bits of the 128 bit result
resultLowReceives the 64 least significant bits of the 128 bit result

◆ separateValues()

static std::vector<std::string> Ocean::Utilities::separateValues ( const std::string &  values,
const char  delimiter = ',',
const bool  removeQuotes = true,
const bool  trim = true 
)
static

Separates a set of given values.

Parameters
valuesSet of values to be separated
delimiterThe delimiter separating the individual values
removeQuotesState determining whether the beginning and ending quotes are removed for each value
trimState determining whether prefix and postfix blanks are removed for each value
Returns
Resulting separated values

◆ smallestPowerOfTwo()

unsigned int Ocean::Utilities::smallestPowerOfTwo ( const unsigned int  value)
inlinestatic

Returns the smallest power of two value that is equal or larger than a given value.

Parameters
valueThe value for that the smallest power of two value is determined, with range [0, 0x80000000]
Returns
Smallest power of two value that is equal or larger

◆ sortHighestToFront2() [1/2]

template<typename T >
void Ocean::Utilities::sortHighestToFront2 ( T &  value0,
T &  value1 
)
static

Sorts two values so that the highest value will finally be the first value.

The sorting is not stable.

Parameters
value0First value
value1Second value
Template Parameters
TData type of the values to be sorted

◆ sortHighestToFront2() [2/2]

template<typename T , typename TData >
void Ocean::Utilities::sortHighestToFront2 ( T &  value0,
T &  value1,
TData &  data0,
TData &  data1 
)
static

Sorts two values so that the highest value will finally be the first value.

Each value has a connected payload data value that will be sorted accordingly.
The sorting is not stable.

Parameters
value0First value
value1Second value
data0First data value
data1Second data value
Template Parameters
TData type of the values to be sorted
TDataData type of the payload data value

◆ sortHighestToFront3() [1/2]

template<typename T >
void Ocean::Utilities::sortHighestToFront3 ( T &  value0,
T &  value1,
T &  value2 
)
static

Sorts three values so that the highest value will finally be the first value.

The sorting is not stable.

Parameters
value0First value
value1Second value
value2Third value
Template Parameters
TData type of the values to be sorted

◆ sortHighestToFront3() [2/2]

template<typename T , typename TData >
void Ocean::Utilities::sortHighestToFront3 ( T &  value0,
T &  value1,
T &  value2,
TData &  data0,
TData &  data1,
TData &  data2 
)
static

Sorts three values so that the highest value will finally be the first value.

Each value has a connected payload data value that will be sorted accordingly.
The sorting is not stable.

Parameters
value0First value
value1Second value
value2Third value
data0First data value
data1Second data value
data2Third data value
Template Parameters
TData type of the values to be sorted
TDataData type of the payload data value

◆ sortLowestToFront2() [1/2]

template<typename T >
void Ocean::Utilities::sortLowestToFront2 ( T &  value0,
T &  value1 
)
static

Sorts two values so that the lowest value will finally be the first value.

The sorting is not stable.

Parameters
value0First value
value1Second value
Template Parameters
TData type of the values to be sorted

◆ sortLowestToFront2() [2/2]

template<typename T , typename TData >
void Ocean::Utilities::sortLowestToFront2 ( T &  value0,
T &  value1,
TData &  data0,
TData &  data1 
)
static

Sorts two values so that the lowest value will finally be the first value.

Each value has a connected data value that will be sorted accordingly.
The sorting is not stable.

Parameters
value0First value
value1Second value
data0First data value
data1Second data value
Template Parameters
TData type of the values to be sorted

◆ sortLowestToFront3() [1/2]

template<typename T >
void Ocean::Utilities::sortLowestToFront3 ( T &  value0,
T &  value1,
T &  value2 
)
static

Sorts three values so that the lowest value will finally be the first value.

The sorting is not stable.

Parameters
value0First value
value1Second value
value2Third value
Template Parameters
TData type of the values to be sorted

◆ sortLowestToFront3() [2/2]

template<typename T , typename TData >
void Ocean::Utilities::sortLowestToFront3 ( T &  value0,
T &  value1,
T &  value2,
TData &  data0,
TData &  data1,
TData &  data2 
)
static

Sorts three values so that the lowest value will finally be the first value.

Each value has a connected data value that will be sorted accordingly.
The sorting is not stable.

Parameters
value0First value
value1Second value
value2Third value
data0First data value
data1Second data value
data2Third data value
Template Parameters
TData type of the values to be sorted

◆ sortPairFirst() [1/2]

template<typename T1 , typename T2 >
bool Ocean::Utilities::sortPairFirst ( const std::pair< T1, T2 > &  firstPair,
const std::pair< T1, T2 > &  secondPair 
)
inlinestatic

Compares two pair objects and returns whether the first value of the first pair is lesser than the first value of the second pair.

Parameters
firstPairFirst pair object
secondPairSecond pair object
Returns
True, if so
Template Parameters
T1The data type of the first value of the pair objects
T2The data type of the second value of the pair objects

◆ sortPairFirst() [2/2]

template<typename T >
bool Ocean::Utilities::sortPairFirst ( const T &  firstPair,
const T &  secondPair 
)
inlinestatic

Compares two pair objects and returns whether the first value of the first pair is lesser than the first value of the second pair.

Parameters
firstPairFirst pair object
secondPairSecond pair object
Returns
True, if so
Template Parameters
TThe data type of the std::pair object

◆ sortPairSecond() [1/2]

template<typename T1 , typename T2 >
bool Ocean::Utilities::sortPairSecond ( const std::pair< T1, T2 > &  firstPair,
const std::pair< T1, T2 > &  secondPair 
)
inlinestatic

Compares two pair objects and returns whether the second value of the first pair is lesser than the second value of the second pair.

Parameters
firstPairFirst pair object
secondPairSecond pair object
Returns
True, if so
Template Parameters
T1The data type of the first value of the pair objects
T2The data type of the second value of the pair objects

◆ sortPairSecond() [2/2]

template<typename T >
bool Ocean::Utilities::sortPairSecond ( const T &  firstPair,
const T &  secondPair 
)
inlinestatic

Compares two pair objects and returns whether the second value of the first pair is lesser than the second value of the second pair.

Parameters
firstPairFirst pair object
secondPairSecond pair object
Returns
True, if so
Template Parameters
TThe data type of the std::pair object

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