Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <dense_set.h>
Public Types | |
using | iterator = typename std::vector<T>::const_iterator |
using | const_iterator = typename std::vector<T>::const_iterator |
using | value_type = T |
Public Member Functions | |
const_iterator | begin () const |
const_iterator | end () const |
size_t | size () const |
bool | empty () const |
void | reserve (size_t size) |
size_t | capacity () const |
std::pair< iterator, bool > | insert (T value) |
iterator | find (T value) |
bool | contains (T value) const |
void | erase (iterator it) |
int | erase (T value) |
absl::Span< const T > | values () const |
void | clear () |
Static Public Attributes | |
static constexpr bool | kAutoResize = auto_resize |
A set of dense non-negative integer values stored in a dense vector.
This is useful when we want to iterate over a small subset of the possible values and reuse the memory, or if we want to randomly sample from the set.
If the set is usually small but occasionally very large, iterating over a regular hash_set would be less efficient as you would (internal to the hash table iterator) have have to iterate over all the buckets in the hash table even if empty. If you clear the set frequently to avoid this, you would grow and rehash when you have a larger set.
If resize=false, users must call reserve(K) where K > any key before calling any other method.
Definition at line 39 of file dense_set.h.
using operations_research::DenseSet< T, auto_resize >::const_iterator = typename std::vector<T>::const_iterator |
Definition at line 42 of file dense_set.h.
using operations_research::DenseSet< T, auto_resize >::iterator = typename std::vector<T>::const_iterator |
Definition at line 41 of file dense_set.h.
using operations_research::DenseSet< T, auto_resize >::value_type = T |
Definition at line 43 of file dense_set.h.
|
inline |
Definition at line 46 of file dense_set.h.
|
inline |
Definition at line 54 of file dense_set.h.
|
inline |
We expect values_ to be much smaller than the total number of possible values, so just clear entries in the set.
Definition at line 104 of file dense_set.h.
|
inline |
Definition at line 74 of file dense_set.h.
|
inline |
Definition at line 49 of file dense_set.h.
|
inline |
Definition at line 47 of file dense_set.h.
|
inline |
This is a hack to allow erase to work with a const iterator.
Definition at line 79 of file dense_set.h.
|
inline |
Definition at line 89 of file dense_set.h.
|
inline |
Definition at line 67 of file dense_set.h.
|
inline |
Definition at line 56 of file dense_set.h.
|
inline |
Definition at line 50 of file dense_set.h.
|
inline |
Definition at line 48 of file dense_set.h.
|
inline |
The ordering is deterministic given the same sequence of inserts and erases but is arbitrary and should not be relied upon.
Definition at line 102 of file dense_set.h.
|
staticconstexpr |
Definition at line 44 of file dense_set.h.