17 #ifndef OR_TOOLS_MATH_OPT_CPP_MAP_FILTER_H_
18 #define OR_TOOLS_MATH_OPT_CPP_MAP_FILTER_H_
21 #include <initializer_list>
25 #include "ortools/math_opt/sparse_containers.pb.h"
53 template <
typename KeyType>
99 SparseVectorFilterProto
Proto()
const;
109 template <
typename KeyType>
121 template <
typename KeyType>
133 template <
typename Collection,
134 typename ValueType =
typename Collection::value_type>
150 template <
typename KeyType>
161 template <
typename KeyType>
163 return filtered_keys ? filtered_keys->storage() :
nullptr;
166 template <
typename KeyType>
168 SparseVectorFilterProto ret;
169 ret.set_skip_zero_values(skip_zero_values);
171 ret.set_filter_by_ids(
true);
172 const auto filtered_ids = ret.mutable_filtered_ids();
173 filtered_ids->Reserve(filtered_keys->size());
174 for (
const auto id : filtered_keys->raw_set()) {
175 filtered_ids->Add(
id.
value());
178 std::sort(filtered_ids->begin(), filtered_ids->end());
MapFilter< KeyType > MakeSkipAllFilter()
MapFilter< ValueType > MakeKeepKeysFilter(const Collection &keys)
MapFilter< KeyType > MakeSkipZerosFilter()
Collection of objects used to extend the Constraint Solver library.
std::optional< IdSet< KeyType > > filtered_keys
SparseVectorFilterProto Proto() const
const ModelStorage * storage() const