16#ifndef OR_TOOLS_UTIL_VECTOR_MAP_H_
17#define OR_TOOLS_UTIL_VECTOR_MAP_H_
21#include "absl/container/flat_hash_map.h"
34 int Add(
const T& element) {
35 int current_index =
Index(element);
36 if (current_index != -1) {
39 const int index = list_.size();
41 list_.push_back(element);
42 map_[element] =
index;
48 void Add(
const std::vector<T>& elements) {
49 for (
int i = 0; i < elements.size(); ++i) {
61 int Index(
const T& element)
const {
81 int size()
const {
return list_.size(); }
90 const std::vector<T>&
list()
const {
return list_; }
112 std::vector<T> list_;
113 absl::flat_hash_map<T, int> map_;
#define CHECK_LT(val1, val2)
#define CHECK_EQ(val1, val2)
#define CHECK_GE(val1, val2)
const std::vector< T > & list() const
const_reverse_iterator rend() const
const T & Element(int index) const
const T & operator[](int index) const
int Add(const T &element)
const_iterator begin() const
std::reverse_iterator< const_iterator > const_reverse_iterator
bool Contains(const T &element) const
int IndexOrDie(const T &element) const
void Add(const std::vector< T > &elements)
static const size_type npos
const_iterator end() const
ptrdiff_t difference_type
const_reverse_iterator rbegin() const
int Index(const T &element) const
const T & const_reference
const Collection::value_type::second_type & FindOrDie(const Collection &collection, const typename Collection::value_type::first_type &key)
bool ContainsKey(const Collection &collection, const Key &key)
const Collection::value_type::second_type & FindWithDefault(const Collection &collection, const typename Collection::value_type::first_type &key, const typename Collection::value_type::second_type &value)
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...