14#ifndef OR_TOOLS_MATH_OPT_ELEMENTAL_ELEMENT_REF_TRACKER_H_
15#define OR_TOOLS_MATH_OPT_ELEMENTAL_ELEMENT_REF_TRACKER_H_
17#include "absl/container/flat_hash_map.h"
18#include "absl/container/flat_hash_set.h"
25template <
typename ValueType,
int n,
typename Symmetry>
29template <
typename Descriptor>
32 Descriptor::kNumKeyElements,
33 typename Descriptor::Symmetry>;
39template <ElementType element_type,
int n,
typename Symmetry>
53 element_id_to_attr_keys_[id].insert(key);
57 const auto it = element_id_to_attr_keys_.find(
id);
58 if (it != element_id_to_attr_keys_.end()) {
59 it->second.erase(key);
60 if (it->second.empty()) {
61 element_id_to_attr_keys_.erase(it);
66 void Clear() { element_id_to_attr_keys_.clear(); }
71 absl::flat_hash_map<ElemId, absl::flat_hash_set<Key>>
72 element_id_to_attr_keys_;
76template <
typename ValueType,
int n,
typename Symmetry>
A strongly typed element id. Value type.
ElementId< element_type > ElemId
void Untrack(const Key key, const ElemId id)
const absl::flat_hash_set< Key > & GetKeysReferencing(const ElemId id) const
Returns the set of keys that reference element id.
void Track(const Key key, const ElemId id)
AttrKey< n, Symmetry > Key
Other value types do not need tracking.
const MapUtilMappedT< Collection > & FindWithDefault(const Collection &collection, const KeyType &key, const MapUtilMappedT< Collection > &value)
An object oriented wrapper for quadratic constraints in ModelStorage.
ElementRefTracker< typename Descriptor::ValueType, Descriptor::kNumKeyElements, typename Descriptor::Symmetry > ElementRefTrackerForAttrTypeDescriptor
The ElementRefTracker for a given attribute type descriptor.