header_utils
|
Functions that operate on containers like maps and vectors. More...
template<typename T , typename U > | |
constexpr auto | ghassanpl::push_back_unique (std::vector< T > &vector, U &&value) |
template<typename T , typename U > | |
constexpr std::optional< T > | ghassanpl::erase_single (std::vector< T > &vector, U &&value) |
Finds a value in the vector, and erases it, but returns the value. | |
template<typename K , typename V , typename COMP , typename U > | |
constexpr std::optional< V > | ghassanpl::erase_single (std::map< K, V, COMP > &map, U &&key) |
Finds a value in the map, and erases it, but returns the value. | |
template<typename T , typename PRED > | |
constexpr std::optional< T > | ghassanpl::erase_single_if (std::vector< T > &vector, PRED &&pred) |
Finds a value in the vector by predicate, and erases it. | |
template<typename T , typename U > | |
constexpr std::optional< T > | ghassanpl::erase_single_swap (std::vector< T > &vector, U &&value) |
Finds and erases a value in vector, not preserving item order (swapping last item to erased) | |
template<typename T , typename PRED > | |
constexpr std::optional< T > | ghassanpl::erase_single_swap_if (std::vector< T > &vector, PRED &&pred) |
Finds and erases a value in vector by predicate, not preserving item order (swapping last item to erased) | |
template<typename T > | |
constexpr std::optional< T > | ghassanpl::erase_at_swap (std::vector< T > &vector, size_t index) |
Erases the element at index in vector, not preserving item order (swapping last item to erased) | |
template<typename KEY , typename MAP > | |
auto | ghassanpl::map_find (MAP &map, KEY &&key) |
Finds the value associated with key in the map and retuns a pointer to it, or nullptr if none found. | |
template<typename DEF , typename KEY , typename MAP > | |
auto | ghassanpl::map_at_or_default (MAP &&map, KEY &&key, DEF &&def) |
Finds the value associated with key in the map and retuns it, or def if none found. | |
template<typename KEY , typename MAP > | |
decltype(auto) | ghassanpl::map_at (MAP &&map, KEY &&key) |
Basically map.at() but works with heterogenous key types. | |
template<typename MAP , typename VAL > | |
auto | ghassanpl::map_find_value (MAP &map, VAL const *value) |
Finds the first value of a map element, and returns a pointer to its key, or nullptr if none found. | |
template<typename K , typename V , typename C , typename VAL > | |
auto | ghassanpl::at_ptr (std::map< K, V, C > const &map, VAL &&value) |
Same as map_find() | |
template<typename K , typename V , typename C , typename VAL > | |
auto | ghassanpl::at_ptr (std::map< K, V, C > &map, VAL &&value) |
Same as map_find() | |
Functions that operate on containers like maps and vectors.
|
constexpr |
Erases the element at index
in vector, not preserving item order (swapping last item to erased)
Definition at line 96 of file containers.h.
|
constexpr |
Finds a value in the map, and erases it, but returns the value.
Definition at line 46 of file containers.h.
|
constexpr |
Finds a value in the vector, and erases it, but returns the value.
Definition at line 34 of file containers.h.
|
constexpr |
Finds a value in the vector by predicate, and erases it.
Definition at line 58 of file containers.h.
|
constexpr |
Finds and erases a value in vector, not preserving item order (swapping last item to erased)
Definition at line 70 of file containers.h.
|
constexpr |
Finds and erases a value in vector by predicate, not preserving item order (swapping last item to erased)
Definition at line 83 of file containers.h.
Basically map.at() but works with heterogenous key types.
Definition at line 126 of file containers.h.
Finds the value associated with key
in the map
and retuns it, or def
if none found.
Definition at line 116 of file containers.h.
Finds the value associated with key
in the map
and retuns a pointer to it, or nullptr if none found.
Definition at line 108 of file containers.h.
Finds the first value
of a map element, and returns a pointer to its key, or nullptr if none found.
Definition at line 146 of file containers.h.