14#ifndef OR_TOOLS_MATH_OPT_CORE_SORTED_H_
15#define OR_TOOLS_MATH_OPT_CORE_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());
34template <
typename K,
typename V>
35std::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);
44template <
typename K,
typename V>
45std::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);
54template <
typename K,
typename V>
56 std::vector<K> keys =
MapKeys(in_map);
57 std::sort(keys.begin(), keys.end());
61template <
typename K,
typename V>
62std::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());
An object oriented wrapper for quadratic constraints in ModelStorage.
std::vector< K > MapKeys(const absl::flat_hash_map< K, V > &in_map)
std::vector< T > SortedSetElements(const absl::flat_hash_set< T > &elements)
std::vector< K > SortedMapKeys(const absl::flat_hash_map< K, V > &in_map)