Loading...
Searching...
No Matches
Namespaces | Classes | Functions
Miscellaneous
Collaboration diagram for Miscellaneous:

Namespaces

namespace  bitpit::utils
 Namespace for generic utility functions.
 

Classes

struct  make_void<... >
 

Functions

template<typename T , typename Comparator = std::less<T>>
bool bitpit::utils::addToOrderedVector (const T &value, std::vector< T > &list, Comparator comparator=Comparator())
 
std::size_t bitpit::utils::countDigits (int n)
 
template<class T >
void bitpit::utils::eraseValue (std::vector< T > &, const T &)
 
void bitpit::utils::extractWithoutReplacement (int n, int m, std::vector< int > &list)
 
unsigned long bitpit::utils::factorial (unsigned long n)
 
template<typename T , typename Comparator = std::less<T>>
std::vector< T >::const_iterator bitpit::utils::findInOrderedVector (const T &value, const std::vector< T > &list, Comparator comparator=Comparator())
 
template<class T >
std::vector< T > bitpit::utils::intersectionVector (const std::vector< T > &, const std::vector< T > &)
 
template<typename T >
auto bitpit::utils::is_iterable_impl (int) -> decltype(std::begin(std::declval< T & >()) !=std::end(std::declval< T & >()),++std::declval< decltype(std::begin(std::declval< T & >()))& >(), *std::begin(std::declval< T & >()), std::true_type{})
 
template<typename OrderContainer , typename DataContainer >
void bitpit::utils::reorderContainer (OrderContainer &order, DataContainer &v, std::size_t size)
 
template<typename T >
void bitpit::utils::reorderVector (std::vector< size_t > &order, std::vector< T > &v, std::size_t size)
 
template<typename Container , typename Index >
void bitpit::utils::swapValue (Container &v, Index i, Index j)
 
template<>
void bitpit::utils::swapValue (std::vector< bool > &v, std::size_t i, std::size_t j)
 

Detailed Description

Function Documentation

◆ addToOrderedVector()

template<typename T , typename Comparator = std::less<T>>
bool bitpit::utils::addToOrderedVector ( const T & value,
std::vector< T > & list,
Comparator comparator )

Adds an id to an ordered list of unique ids.

Template Parameters
Tis the type of elements contained in the list
Comparatoris the type of the binary function used for the comparison of the elements
Parameters
valueis the value to be added
listis the ordered list
comparatoris a binary function that accepts two arguments (the first of the type pointed by ForwardIterator, and the second, always val), and returns a value convertible to bool. The value returned indicates whether the first argument is considered to go before the second. The function shall not modify any of its arguments. This can either be a function pointer or a function object.
Returns
Returns true is the id was added to the list, false otherwise.

Definition at line 54 of file commonUtils.tpp.

◆ countDigits()

std::size_t bitpit::utils::countDigits ( int n)

Count the number of digits of the given number.

Parameters
[in]nis number whose digits should be counted
Returns
The number of digits of the specified number.

Definition at line 103 of file commonUtils.cpp.

◆ eraseValue()

template<class T >
void bitpit::utils::eraseValue ( std::vector< T > & vec,
const T & value )

Remove a element with specified value from input std::vector.

Parameters
[in,out]vecis the inptut vector set. On output stores the input vector deprived by the element with specified value
[in]valueis the value of element to be removed from the input vector

Definition at line 170 of file commonUtils.tpp.

◆ extractWithoutReplacement()

void bitpit::utils::extractWithoutReplacement ( int n,
int m,
std::vector< int > & list )

Extract n integers in the interval [0,m] without replacement. if n = m+1, returns a random permutation of {0, 1, 2, ..., m}

Parameters
[in]nis the number of extraction
[in]mis the upper bound of extraction interval
[in,out]listis a vector with size n, storing extracted values

Definition at line 67 of file commonUtils.cpp.

◆ factorial()

unsigned long bitpit::utils::factorial ( unsigned long n)

Compute the factorial of the specified number.

Parameters
[in]nis the argument for which the factorial has to be evaluated
Returns
The factorial of the specified number.

Definition at line 126 of file commonUtils.cpp.

◆ findInOrderedVector()

template<typename T , typename Comparator = std::less<T>>
std::vector< T >::const_iterator bitpit::utils::findInOrderedVector ( const T & value,
const std::vector< T > & list,
Comparator comparator )

Search a value in an ordered list of unique ids.

Template Parameters
Tis the type of elements contained in the list
Comparatoris the type of the binary function used for the comparison of the elements
Parameters
valueis the value to be searched for
listis the ordered list
comparatoris a binary function that accepts two arguments (the first of the type pointed by ForwardIterator, and the second, always val), and returns a value convertible to bool. The value returned indicates whether the first argument is considered to go before the second. The function shall not modify any of its arguments. This can either be a function pointer or a function object.
Returns
Returns true is the value is in the list, false otherwise.

Definition at line 90 of file commonUtils.tpp.

◆ intersectionVector()

template<class T >
std::vector< T > bitpit::utils::intersectionVector ( const std::vector< T > & vec_1,
const std::vector< T > & vec_2 )

Compute intersection between two std::vectors.

Parameters
[in]vec_1is the 1st argument for intersection.
[in]vec_2is the 2nd argument for intersection.
Returns
Returns a vector storing the common elements of the input vectors.

Definition at line 188 of file commonUtils.tpp.

◆ is_iterable_impl()

template<typename T >
auto bitpit::utils::is_iterable_impl ( int ) -> decltype(std::begin(std::declval< T & >()) !=std::end(std::declval< T & >()),++std::declval< decltype(std::begin(std::declval< T & >()))& >(), *std::begin(std::declval< T & >()), std::true_type{})

Check if a type is iterable

◆ reorderContainer()

template<typename OrderContainer , typename DataContainer >
void bitpit::utils::reorderContainer ( OrderContainer & order,
DataContainer & v,
std::size_t size )

Order a container according to a reordering vector.

Template Parameters
OrderContaineris the type of container that stores ordering information
DataContaineris the type of container that stores the data
Parameters
orderis a reference to the reording container, on output the contents of the container will be destroyed
vis a reference to the container that will be reordered
sizeis the size of the container that will be reordered

Definition at line 130 of file commonUtils.tpp.

◆ reorderVector()

template<typename T >
void bitpit::utils::reorderVector ( std::vector< size_t > & order,
std::vector< T > & v,
std::size_t size )

Order a vector according to a reordering vector.

Template Parameters
Tis the type of data that needs to be reordered
Parameters
orderis a reference to the reording vector, on output the contents of the vector will be destroyed
vis a reference to the vector that will be reordered
sizeis the size of the vector that will be reordered

Definition at line 112 of file commonUtils.tpp.

◆ swapValue() [1/2]

template<typename Container , typename Index >
void bitpit::utils::swapValue ( Container & v,
Index i,
Index j )

Swap two values stored in the specified container.

Template Parameters
Containeris the type of container that stores the data
Indexis the type of the index that allows to identify a value in the container
Parameters
vis a reference to the container
iis the index of the first element that will be swapped
jis the index of the second element that will be swapped

Definition at line 155 of file commonUtils.tpp.

◆ swapValue() [2/2]

template<>
void bitpit::utils::swapValue ( std::vector< bool > & v,
std::size_t i,
std::size_t j )

Swap two values stored in the specified std::vector<bool> container.

Parameters
vis a reference to the container
iis the index of the first element that will be swapped
jis the index of the second element that will be swapped

Definition at line 52 of file commonUtils.cpp.

--- layout: doxygen_footer ---