|
size_t | size () const |
| Size of the "key" space, always in [0, size()).
|
|
bool | empty () const |
|
absl::Span< V > | operator[] (K key) |
|
absl::Span< const V > | operator[] (K key) const |
|
std::vector< absl::Span< const V > > | AsVectorOfSpan () const |
|
void | clear () |
| Restore to empty vector<vector<>>.
|
|
void | reserve (int size) |
| Reserve memory if it is already known or tightly estimated.
|
|
void | reserve (int size, int num_terms) |
|
template<typename Keys , typename Values > |
void | ResetFromFlatMapping (Keys keys, Values values) |
|
void | ResetFromTranspose (const CompactVectorVector< V, K > &other, int min_transpose_size=0) |
| Similar to ResetFromFlatMapping().
|
|
int | Add (absl::Span< const V > values) |
|
template<typename L > |
int | AddLiterals (const std::vector< L > &wrapped_values) |
|
void | RemoveBySwap (K key, int index) |
|
void | ReplaceValuesBySmallerSet (K key, absl::Span< const V > values) |
|
void | emplace_back (V const *begin, V const *end) |
|
template<typename K = int, typename V = int>
class operations_research::sat::CompactVectorVector< K, V >
Small utility class to store a vector<vector<>> where one can only append new vector and never change previously added ones. This allows to store a static key -> value(s) mapping.
This is a lot more compact memorywise and thus faster than vector<vector<>>.
- Note
- we implement a really small subset of the vector<vector<>> API.
We support int and StrongType for key K and any copyable type for value V.
Definition at line 69 of file util.h.
template<typename K = int, typename V = int>
We lied when we said this is a pure read-only class :) It is possible to shrink inner vectors with not much cost.
Removes the element at index from this[key] by swapping it with this[key].back() and then decreasing this key size. It is an error to call this on an empty inner vector.
Definition at line 130 of file util.h.
template<typename K , typename V >
template<typename Keys , typename Values >
Given a flat mapping (keys[i] -> values[i]) with two parallel vectors, not necessarily sorted by key, regroup the same key so that CompactVectorVector[key] list all values in the order in which they appear.
We only check keys.size(), so this can be used with IdentityMap() as second argument.
Compute maximum index.
Compute sizes_;
Compute starts_;
Copy data and uses starts as temporary indices.
Restore starts_.
Definition at line 830 of file util.h.
template<typename K , typename V >
Similar to ResetFromFlatMapping().
Initialize this vector from the transpose of another. IMPORTANT: This cannot be called with the vector itself.
If min_transpose_size is given, then the transpose will have at least this size even if some of the last keys do not appear in other.
If this is called twice in a row, then it has the side effect of sorting all inner vectors by values !
Compute maximum index.
Compute sizes_;
Compute starts_;
Copy data and uses starts as temporary indices.
Restore starts_.
Definition at line 867 of file util.h.