14 #ifndef OR_TOOLS_MATH_OPT_STORAGE_SORTED_H_
15 #define OR_TOOLS_MATH_OPT_STORAGE_SORTED_H_
20 #include "absl/algorithm/container.h"
21 #include "absl/container/flat_hash_map.h"
22 #include "absl/container/flat_hash_set.h"
23 #include "google/protobuf/map.h"
29 std::vector<T> result(elements.begin(), elements.end());
34 template <
typename K,
typename V>
35 std::vector<K>
MapKeys(
const absl::flat_hash_map<K, V>& in_map) {
37 keys.reserve(in_map.size());
38 for (
const auto& key_pair : in_map) {
39 keys.push_back(key_pair.first);
44 template <
typename K,
typename V>
45 std::vector<K>
MapKeys(
const google::protobuf::Map<K, V>& in_map) {
47 keys.reserve(in_map.size());
48 for (
const auto& key_pair : in_map) {
49 keys.push_back(key_pair.first);
54 template <
typename K,
typename V>
56 std::vector<K> keys =
MapKeys(in_map);
57 std::sort(keys.begin(), keys.end());
61 template <
typename K,
typename V>
62 std::vector<K>
SortedMapKeys(
const google::protobuf::Map<K, V>& in_map) {
63 std::vector<K> keys =
MapKeys(in_map);
64 std::sort(keys.begin(), keys.end());
std::vector< K > MapKeys(const absl::flat_hash_map< K, V > &in_map)
std::vector< K > SortedMapKeys(const absl::flat_hash_map< K, V > &in_map)
std::vector< T > SortedElements(const absl::flat_hash_set< T > &elements)