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) |
bool bitpit::utils::addToOrderedVector | ( | const T & | value, |
std::vector< T > & | list, | ||
Comparator | comparator ) |
Adds an id to an ordered list of unique ids.
T | is the type of elements contained in the list |
Comparator | is the type of the binary function used for the comparison of the elements |
value | is the value to be added |
list | is the ordered list |
comparator | is 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. |
Definition at line 54 of file commonUtils.tpp.
std::size_t bitpit::utils::countDigits | ( | int | n | ) |
Count the number of digits of the given number.
[in] | n | is number whose digits should be counted |
Definition at line 103 of file commonUtils.cpp.
void bitpit::utils::eraseValue | ( | std::vector< T > & | vec, |
const T & | value ) |
Remove a element with specified value from input std::vector.
[in,out] | vec | is the inptut vector set. On output stores the input vector deprived by the element with specified value |
[in] | value | is the value of element to be removed from the input vector |
Definition at line 170 of file commonUtils.tpp.
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}
[in] | n | is the number of extraction |
[in] | m | is the upper bound of extraction interval |
[in,out] | list | is a vector with size n, storing extracted values |
Definition at line 67 of file commonUtils.cpp.
unsigned long bitpit::utils::factorial | ( | unsigned long | n | ) |
Compute the factorial of the specified number.
[in] | n | is the argument for which the factorial has to be evaluated |
Definition at line 126 of file commonUtils.cpp.
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.
T | is the type of elements contained in the list |
Comparator | is the type of the binary function used for the comparison of the elements |
value | is the value to be searched for |
list | is the ordered list |
comparator | is 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. |
Definition at line 90 of file commonUtils.tpp.
std::vector< T > bitpit::utils::intersectionVector | ( | const std::vector< T > & | vec_1, |
const std::vector< T > & | vec_2 ) |
Compute intersection between two std::vectors.
[in] | vec_1 | is the 1st argument for intersection. |
[in] | vec_2 | is the 2nd argument for intersection. |
Definition at line 188 of file commonUtils.tpp.
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
void bitpit::utils::reorderContainer | ( | OrderContainer & | order, |
DataContainer & | v, | ||
std::size_t | size ) |
Order a container according to a reordering vector.
OrderContainer | is the type of container that stores ordering information |
DataContainer | is the type of container that stores the data |
order | is a reference to the reording container, on output the contents of the container will be destroyed |
v | is a reference to the container that will be reordered |
size | is the size of the container that will be reordered |
Definition at line 130 of file commonUtils.tpp.
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.
T | is the type of data that needs to be reordered |
order | is a reference to the reording vector, on output the contents of the vector will be destroyed |
v | is a reference to the vector that will be reordered |
size | is the size of the vector that will be reordered |
Definition at line 112 of file commonUtils.tpp.
void bitpit::utils::swapValue | ( | Container & | v, |
Index | i, | ||
Index | j ) |
Swap two values stored in the specified container.
Container | is the type of container that stores the data |
Index | is the type of the index that allows to identify a value in the container |
v | is a reference to the container |
i | is the index of the first element that will be swapped |
j | is the index of the second element that will be swapped |
Definition at line 155 of file commonUtils.tpp.
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.
v | is a reference to the container |
i | is the index of the first element that will be swapped |
j | is the index of the second element that will be swapped |
Definition at line 52 of file commonUtils.cpp.