|
template<class output_t , class input_t , std::size_t SIZE> |
constexpr std::array< output_t, SIZE > | static_cast_copy_array (const std::array< input_t, SIZE > &a) |
| Creates a new array by performing an element-wise static_cast<>.
|
|
template<class Container , class Fun > |
void | to_string (std::ostream &os, const Container &container, const std::string &delimiter, const std::array< std::string, 2 > &surround, Fun elemToString) |
| Generates a string representation of a container which fulfills the Container requirement (provide cbegin and cend) and appends it to a stream.
|
|
template<class Container > |
void | to_string (std::ostream &os, const Container &container, const std::string &delimiter=", ", const std::array< std::string, 2 > &surround={"[", "]"}) |
| Version of to_string() with simpler signature and default arguments.
|
|
template<class Container , class Fun > |
std::string | to_string (const Container &container, const std::string &delimiter, const std::array< std::string, 2 > &surround, Fun elemToString) |
| Generates a string representation of a container which fulfills the Container requirement (provide cbegin and cend).
|
|
template<class Container > |
std::string | to_string (const Container &container, const std::string &delimiter=", ", const std::array< std::string, 2 > &surround={"[", "]"}) |
| Version of to_string() with simpler signature and default arguments.
|
|
template<class Container > |
std::enable_if_t< autopas::utils::ArrayUtils::is_container< Container >::value, std::ostream & > | operator<< (std::ostream &os, const Container &container) |
| Stream operator for containers (array and vector types).
|
|
template<class OuterContainerT > |
void | balanceVectors (OuterContainerT &vecvec) |
| Given a collection of vectors, redistributes the elements of the vectors so they all have the same (or +1) size.
|
|
template<class OuterContainerT , class F > |
void | balanceVectors (OuterContainerT &vecvec, F innerContainerToVec) |
| Given a collection of containers that hold vectors, redistributes the elements of the vectors so they all have the same (or +1) size.
|
|
In this namespace some helper functions for std::array can be found.
template<class OuterContainerT , class F >
void autopas::utils::ArrayUtils::balanceVectors |
( |
OuterContainerT & |
vecvec, |
|
|
F |
innerContainerToVec |
|
) |
| |
Given a collection of containers that hold vectors, redistributes the elements of the vectors so they all have the same (or +1) size.
Elements are taken from the ends of too-long vectors and appended to the ends of too-short vectors. The overall ordering of elements is not preserved.
- Template Parameters
-
OuterContainerT | Collection type |
F | Type of the function innerContainerToVec |
- Parameters
-
vecvec | Reference to the collection of vectors to be balanced in place. |
innerContainerToVec | Function to map inner containers to std::vector&. |
template<class output_t , class input_t , std::size_t SIZE>
constexpr std::array< output_t, SIZE > autopas::utils::ArrayUtils::static_cast_copy_array |
( |
const std::array< input_t, SIZE > & |
a | ) |
|
|
constexpr |
Creates a new array by performing an element-wise static_cast<>.
- Note
- This function returns a new copy of the array with the desired type!
Even though this is implemented to copy the array, compilers optimize this away: https://gcc.godbolt.org/z/6dav1PEGP
- Template Parameters
-
output_t | Output type. |
input_t | Input type. |
SIZE | Size of the array. |
- Parameters
-
- Returns
- Array of type std::array<output_t, SIZE>.