![]() |
Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
|
#include <element_storage.h>
Public Member Functions | |
ElementStorage () | |
int64_t | Add (const absl::string_view name) |
Creates a new element and returns its id. | |
bool | Erase (const int64_t id) |
bool | Exists (const int64_t id) const |
Returns true an element with this id was created and not yet erased. | |
absl::StatusOr< absl::string_view > | GetName (const int64_t id) const |
int64_t | next_id () const |
std::vector< int64_t > | AllIds () const |
int64_t | size () const |
Returns the number of elements added and not erased. | |
void | EnsureNextIdAtLeast (const int64_t id) |
Definition at line 107 of file element_storage.h.
|
inline |
We start with a dense storage, which is more efficient, and switch to a sparse storage when an element is erased.
Definition at line 128 of file element_storage.h.
|
inline |
Creates a new element and returns its id.
Definition at line 131 of file element_storage.h.
std::vector< int64_t > operations_research::math_opt::ElementStorage::AllIds | ( | ) | const |
Returns all ids of all elements in the model in an unsorted, non-deterministic order.
Definition at line 52 of file element_storage.cc.
|
inline |
Increases next_id() to id if it is currently less than id.
Useful for reading a model back from proto, most users should not need to call this directly.
Definition at line 171 of file element_storage.h.
|
inline |
Deletes an element by id, returning true on success and false if no element was deleted (it was already deleted or the id was not from any existing element).
Definition at line 138 of file element_storage.h.
|
inline |
Returns true an element with this id was created and not yet erased.
Definition at line 141 of file element_storage.h.
|
inline |
Returns the name of this element, or CHECK fails if no element with this id exists.
Definition at line 147 of file element_storage.h.
|
inline |
Returns the id that will be used for the next element added.
Definition at line 154 of file element_storage.h.
|
inline |
Returns the number of elements added and not erased.
Definition at line 163 of file element_storage.h.