... | ... |
@@ -229,62 +229,83 @@ |
229 | 229 |
} |
230 | 230 |
|
231 | 231 |
/// \e |
232 | 232 |
void set(const Key &k, const T &t) { |
233 | 233 |
typename Map::iterator it = _map.lower_bound(k); |
234 | 234 |
if (it != _map.end() && !_map.key_comp()(k, it->first)) |
235 | 235 |
it->second = t; |
236 | 236 |
else |
237 | 237 |
_map.insert(it, std::make_pair(k, t)); |
238 | 238 |
} |
239 | 239 |
|
240 | 240 |
/// \e |
241 | 241 |
void setAll(const T &t) { |
242 | 242 |
_value = t; |
243 | 243 |
_map.clear(); |
244 | 244 |
} |
245 | 245 |
|
246 | 246 |
}; |
247 | 247 |
|
248 | 248 |
///Returns a \c StdMap class |
249 | 249 |
|
250 | 250 |
///This function just returns a \c StdMap class with specified |
251 | 251 |
///default value. |
252 | 252 |
///\relates StdMap |
253 |
template<typename K, typename V, typename Compare |
|
253 |
template<typename K, typename V, typename Compare> |
|
254 | 254 |
inline StdMap<K, V, Compare> stdMap(const V& value = V()) { |
255 | 255 |
return StdMap<K, V, Compare>(value); |
256 | 256 |
} |
257 |
|
|
258 |
///Returns a \c StdMap class |
|
259 |
|
|
260 |
///This function just returns a \c StdMap class with specified |
|
261 |
///default value. |
|
262 |
///\relates StdMap |
|
263 |
template<typename K, typename V> |
|
264 |
inline StdMap<K, V, std::less<K> > stdMap(const V& value = V()) { |
|
265 |
return StdMap<K, V, std::less<K> >(value); |
|
266 |
} |
|
267 |
|
|
268 |
///Returns a \c StdMap class created from an appropriate std::map |
|
269 |
|
|
270 |
///This function just returns a \c StdMap class created from an |
|
271 |
///appropriate std::map. |
|
272 |
///\relates StdMap |
|
273 |
template<typename K, typename V, typename Compare> |
|
274 |
inline StdMap<K, V, Compare> stdMap( const std::map<K, V, Compare> &map, |
|
275 |
const V& value = V() ) { |
|
276 |
return StdMap<K, V, Compare>(map, value); |
|
277 |
} |
|
257 | 278 |
|
258 | 279 |
///Returns a \c StdMap class created from an appropriate std::map |
259 | 280 |
|
260 | 281 |
///This function just returns a \c StdMap class created from an |
261 | 282 |
///appropriate std::map. |
262 | 283 |
///\relates StdMap |
263 |
template<typename K, typename V, typename Compare = std::less<K> > |
|
264 |
inline StdMap<K, V, Compare> stdMap( const std::map<K, V, Compare> &map, |
|
265 |
const V& value = V() ) { |
|
266 |
return StdMap<K, V, Compare>(map, value); |
|
284 |
template<typename K, typename V> |
|
285 |
inline StdMap<K, V, std::less<K> > stdMap( const std::map<K, V, std::less<K> > &map, |
|
286 |
const V& value = V() ) { |
|
287 |
return StdMap<K, V, std::less<K> >(map, value); |
|
267 | 288 |
} |
268 | 289 |
|
269 | 290 |
/// \brief Map for storing values for keys from the range <tt>[0..size-1]</tt> |
270 | 291 |
/// |
271 | 292 |
/// This map has the <tt>[0..size-1]</tt> keyset and the values |
272 | 293 |
/// are stored in a \c std::vector<T> container. It can be used with |
273 | 294 |
/// some data structures, for example \c UnionFind, \c BinHeap, when |
274 | 295 |
/// the used items are small integer numbers. |
275 | 296 |
/// This map meets the \ref concepts::ReferenceMap "ReferenceMap" concept. |
276 | 297 |
/// |
277 | 298 |
/// \todo Revise its name |
278 | 299 |
template <typename T> |
279 | 300 |
class IntegerMap : public MapBase<int, T> { |
280 | 301 |
|
281 | 302 |
template <typename T1> |
282 | 303 |
friend class IntegerMap; |
283 | 304 |
|
284 | 305 |
public: |
285 | 306 |
|
286 | 307 |
typedef MapBase<int, T> Parent; |
287 | 308 |
///\e |
288 | 309 |
typedef typename Parent::Key Key; |
289 | 310 |
///\e |
290 | 311 |
typedef typename Parent::Value Value; |
0 comments (0 inline)