![]() |
Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
|
#include <attr_storage.h>
Public Types | |
using | Key = AttrKey<n, Symmetry> |
Public Member Functions | |
AttrStorage () | |
Generally avoid, provided to make working with std::array easier. | |
AttrStorage (const V default_value) | |
AttrStorage (const AttrStorage &)=default | |
AttrStorage & | operator= (const AttrStorage &)=default |
AttrStorage (AttrStorage &&)=default | |
AttrStorage & | operator= (AttrStorage &&)=default |
bool | IsNonDefault (const Key key) const |
std::optional< V > | Set (const Key key, const V value) |
V | Get (const Key key) const |
std::optional< V > | GetIfNonDefault (const Key key) const |
Returns the value of the attribute for key, or nullopt. | |
void | Erase (const Key key) |
Sets the value of the attribute for key to the default value. | |
std::vector< Key > | NonDefaults () const |
template<int i> | |
std::vector< Key > | Slice (const int64_t key_elem) const |
template<int i> | |
int64_t | GetSliceSize (const int64_t key_elem) const |
int64_t | num_non_defaults () const |
void | Clear () |
Restore all elements to their default value for this attribute. |
Stores the value of an attribute keyed on n elements (e.g. linear_constraint_coefficient is a double valued attribute keyed first on LinearConstraint and then on Variable).
Memory usage: Storing k elements with non-default values in a AttrStorage<V, n> uses sizeof(V) * (n^2 + 1) * k / load_factor (where load_factor is the absl hash map load factor, typically 0.8), plus a small allocation overhead of O(k).
Definition at line 299 of file attr_storage.h.
using operations_research::math_opt::AttrStorage< V, n, Symmetry >::Key = AttrKey<n, Symmetry> |
Definition at line 301 of file attr_storage.h.
|
inlineexplicit |
Generally avoid, provided to make working with std::array easier.
If this no longer holds, we should sprinkle the code with moves and return Vs by ref.
Definition at line 307 of file attr_storage.h.
|
inlineexplicit |
The default value of the attribute is its value when the model is created (e.g. for linear_constraint_coefficient, 0.0).
Definition at line 311 of file attr_storage.h.
|
default |
|
default |
|
inline |
Restore all elements to their default value for this attribute.
Definition at line 416 of file attr_storage.h.
|
inline |
Sets the value of the attribute for key to the default value.
Definition at line 366 of file attr_storage.h.
|
inline |
Returns the value of the attribute for key (return the default value if the attribute value for key is unset).
Definition at line 352 of file attr_storage.h.
|
inline |
Returns the value of the attribute for key, or nullopt.
Definition at line 357 of file attr_storage.h.
|
inline |
Returns the size of the given slice: This is equivalent to Slice(key_elem).size(), but O(1).
Definition at line 402 of file attr_storage.h.
|
inline |
Returns true if the attribute for key has a value different from its default.
Definition at line 320 of file attr_storage.h.
|
inline |
Returns the keys (ids pairs) the of the elements with a non-default value for this attribute.
Definition at line 374 of file attr_storage.h.
|
inline |
Returns the number of keys (element pairs) with non-default values for this attribute.
Definition at line 413 of file attr_storage.h.
|
default |
|
default |
|
inline |
Returns the previous value if value has changed, otherwise returns std::nullopt.
!is_default and !inserted
Definition at line 326 of file attr_storage.h.
|
inline |
Returns the set of all keys K such that:
Definition at line 388 of file attr_storage.h.