Utility functions for std::map manipulation.
More...
|
| template<typename K, typename V> |
| std::map< V, std::set< K > > | invert (std::map< K, V > const &map) |
| | Invert a map: values become keys, original keys are grouped into sets.
|
| |
| template<typename K, typename V> |
| std::set< K > | keys (std::map< K, V > const &map) |
| | Extract all keys from a map as a set.
|
| |
| template<typename Size> |
| std::vector< int > | range_vector (Size n) |
| | Build the sequence [0, 1, ..., n - 1] as std::vector<int>.
|
| |
| template<typename K, typename V> |
| std::set< V > | values (std::map< K, V > const &map) |
| | Extract all values from a map as a set.
|
| |
Utility functions for std::map manipulation.
◆ invert()
template<typename K, typename V>
| std::map< V, std::set< K > > ppforest2::utils::invert |
( |
std::map< K, V > const & | map | ) |
|
Invert a map: values become keys, original keys are grouped into sets.
- Parameters
-
- Returns
- Inverted map {V → set<K>}.
◆ keys()
template<typename K, typename V>
| std::set< K > ppforest2::utils::keys |
( |
std::map< K, V > const & | map | ) |
|
Extract all keys from a map as a set.
- Parameters
-
- Returns
- Set of all keys.
◆ range_vector()
template<typename Size>
| std::vector< int > ppforest2::utils::range_vector |
( |
Size | n | ) |
|
|
inline |
Build the sequence [0, 1, ..., n - 1] as std::vector<int>.
Replaces the pattern
std::vector<int> v(n);
std::iota(v.begin(), v.end(), 0);
which appears anywhere we need a permutation buffer or a "select all
rows/columns" index list. int is the right element type for every caller in the codebase: Eigen's indexed assignment, Eigen column selection, and the strategy Result types all consume int indices.
- Template Parameters
-
| Size | Any integral type (e.g. int, std::size_t, Eigen::Index). Cast to std::size_t for the std::vector constructor. |
- Parameters
-
| n | Length of the resulting sequence (must be >= 0). |
◆ values()
template<typename K, typename V>
| std::set< V > ppforest2::utils::values |
( |
std::map< K, V > const & | map | ) |
|
Extract all values from a map as a set.
- Parameters
-
- Returns
- Set of all values (duplicates collapsed).