38 template <
class KeyT,
class ValT,
39 class KeyContT = std::vector<KeyT>,
40 class ValContT = std::vector<ValT>,
41 class IdxT =
typename ValContT::size_type,
42 class MapT = std::map<KeyT, IdxT >>
47 IdxT
index(
const KeyT& k)
const;
51 ValT
const&
at(IdxT i)
const;
52 ValT&
at(
const KeyT& k);
53 ValT
const&
at(
const KeyT& k)
const;
54 ValT&
at(
const KeyT& k, ValT& defaultVal);
55 ValT
const&
at(
const KeyT& k,
const ValT& defaultVal)
const;
57 ValContT
const&
values()
const;
59 KeyContT
const&
keys()
const;
60 IdxT
count(
const KeyT& k)
const;
61 bool has(
const KeyT& k)
const;
79 static std::string DescribeKey(
const T* key);
80 static std::string DescribeKey(...);
91 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
94 if (indices_.find(key) != indices_.end())
96 throw std::invalid_argument {
"Already added a value for this key" + DescribeKey(&key)};
98 indices_.emplace(key, size());
99 values_.emplace_back(std::move(
value));
100 keys_.emplace_back(std::move(key));
103 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
106 return indices_.at(k);
109 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
112 return values_.at(i);
115 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
118 return values_.at(i);
121 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
127 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
133 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
136 return has(k) ? at(
index(k)) : defaultVal;
139 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
142 return has(k) ? at(
index(k)) : defaultVal;
145 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
148 return values_.size();
151 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
157 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
163 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
169 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
172 return indices_.count(k);
175 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
178 return indices_.count(k);
181 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
189 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
193 return values_.begin();
196 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
200 return values_.end();
203 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
207 return values_.cbegin();
210 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
214 return values_.cend();
217 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
224 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
231 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
237 template <
class KeyT,
class ValT,
class KeyContT,
class ValContT,
class IdxT,
class MapT>
238 template<
class T,
class>
239 std::string KeyValueVector<KeyT, ValT, KeyContT, ValContT, IdxT, MapT>::DescribeKey(
const T* key)