32 template <
typename Key,
typename Value>
33 using MapKey = std::pair<Key, Value>;
35 template <
typename Key,
typename Value>
38 template <
typename... Args>
40 decltype(std::make_pair(std::forward<Args>(args)...))
42 return std::make_pair(std::forward<Args>(args)...);
45 template <
typename... Args>
47 decltype(std::make_pair(std::forward<Args>(args)...))
49 return std::make_pair(std::forward<Args>(args)...);
52 template <
typename Key,
typename Value>
58 template <
typename Key,
typename Value>
64 template <
typename Key,
typename Value>
70 template <
typename Key,
typename Value>
73 return key(*item_ptr);
76 template <
typename Key,
typename Value>
82 template <
typename Key,
typename Value>
88 template <
typename Key,
typename Value>
94 template <
typename Key,
typename Value>
97 return value(*item_ptr);
100 template <
typename Key,
typename Value,
class Cmp>
127 std::swap(cmp, cw.cmp);
151 std::swap(cmp, cw.cmp);
158 return cmp(p.first, q.first);
163 template <
typename Key,
typename Value,
class Cmp,
class BaseSet>
168 using BaseSet::BaseSet;
178 return BaseSet::get_cmp().get_cmp();
183 return BaseSet::get_cmp().get_cmp();
186 Value *
insert(
const Key & k,
const Value & v)
190 Item * result = BaseSet::insert(std::move(p));
192 if (result ==
nullptr)
195 return &result->second;
198 Value *
insert(Key && k,
const Value & v)
200 Item p =
map_key(std::forward<Key>(k), v);
202 Item * result = BaseSet::insert(std::move(p));
204 if (result ==
nullptr)
207 return &result->second;
210 Value *
insert(
const Key & k, Value && v)
212 Item p =
map_key(k, std::forward<Value>(v));
214 Item * result = BaseSet::insert(std::move(p));
216 if (result ==
nullptr)
219 return &result->second;
224 Item p =
map_key(std::forward<Key>(k), std::forward<Value>(v));
226 Item * result = BaseSet::insert(std::move(p));
228 if (result ==
nullptr)
231 return &result->second;
234 Value *
append(
const Key & k,
const Value & v)
239 Value *
append(Key && k,
const Value & v)
241 return insert(std::forward<Key>(k), v);
244 Value *
append(
const Key & k, Value && v)
246 return insert(k, std::forward<Value>(v));
251 return insert(std::forward<Key>(k), std::forward<Value>(v));
258 Item * result = BaseSet::search(p);
260 if (result ==
nullptr)
263 return &result->second;
268 Item p =
map_key(std::forward<Key>(k), Value());
270 Item * result = BaseSet::search(p);
272 if (result ==
nullptr)
275 return &result->second;
278 const Value *
search(
const Key & k)
const 282 const Item * result = BaseSet::search(p);
284 if (result ==
nullptr)
287 return &result->second;
292 Item p =
map_key(std::forward<Key>(k), Value());
294 const Item * result = BaseSet::search(p);
296 if (result ==
nullptr)
299 return &result->second;
305 return &BaseSet::search_or_insert(std::move(p))->second;
310 Item p =
map_key(std::forward<Key>(k), v);
311 return &BaseSet::search_or_insert(std::move(p))->second;
316 Item p =
map_key(k, std::forward<Value>(v));
317 return &BaseSet::search_or_insert(std::move(p))->second;
322 Item p =
map_key(std::forward<Key>(k), std::forward<Value>(v));
323 return &BaseSet::search_or_insert(std::move(p))->second;
328 return search_or_insert(k, Value());
333 return search_or_insert(std::forward<Key>(k), Value());;
339 return BaseSet::find(std::move(p)).second;
342 const Value &
find(
const Key & k)
const 345 return BaseSet::find(std::move(p)).second;
350 Item p =
map_key(std::forward<Key>(k), Value());
351 return BaseSet::find(std::move(p)).second;
354 const Value &
find(Key && k)
const 356 Item p =
map_key(std::forward<Key>(k), Value());
357 return BaseSet::find(std::move(p)).second;
360 bool has(
const Key & k)
const 363 return BaseSet::has(std::move(p));
368 Item p =
map_key(std::forward<Key>(k), Value());
369 return BaseSet::has(std::move(p));
372 bool remove(
const Key & k)
375 return BaseSet::remove(p);
378 Value & operator [] (
const Key & k)
380 return *search_or_insert(k);
383 const Value & operator [] (
const Key & k)
const 385 return *search_or_insert(k);
388 Value & operator [] (Key && k)
390 return *search_or_insert(std::forward<Key>(k));
393 const Value & operator [] (Key && k)
const 395 return *search_or_insert(std::forward<Key>(k));
399 template <
typename Key,
typename Value,
class Cmp = std::less<Key>,
402 ArraySet<MapKey<Key, Value>,
403 CmpWrapper<Key, Value, Cmp>,
464 template <
typename Key,
typename Value,
class Cmp = std::less<Key>,
465 template <
typename,
class>
class TreeType =
RankedTreap>
467 TreeSet<MapKey<Key, Value>,
468 CmpWrapper<Key, Value, Cmp>,
502 TreeMap(
const std::initializer_list<Item> & l)
536 template<
typename Key,
typename Value,
typename Fct>
542 template <
typename Key,
typename Value,
class Cmp = std::equal_to<Key>,
543 template <
typename,
class>
class HashTableType =
LHashTable>
545 HashSet<MapKey<Key, Value>,
546 CmpWrapper<Key, Value, Cmp>,
553 using HashFctPtr =
nat_t (*) (
const Key &);
554 using HashFctType = std::function<nat_t(const Key &)>;
562 std::placeholders::_1)), fct(_fct)
576 std::placeholders::_1)), fct(_fct)
587 HashMap(
const std::initializer_list<Item> &);
620 std::swap(fct, map.fct);
634 template <
typename Key,
typename Value,
class Cmp,
635 template <
typename,
class>
class HashTableType>
637 HashMap(
const std::initializer_list<Item> & l)
640 for (
const auto & item : l)
641 BaseHash::append(item);
TreeMap(rng_seed_t seed, Cmp &&_cmp=Cmp())
Definition: map.H:496
const Cmp & get_cmp() const
Definition: map.H:181
nat_t(*)(const MapKey< Node< GT > *, Arc< GT > ** > &) HashFctPtr
Definition: hash.H:87
Value & find(const Key &k)
Definition: map.H:336
ArrayMap(const ArrayMap &map)
Definition: map.H:436
Value * append(const Key &k, Value &&v)
Definition: map.H:244
const Value * search(const Key &k) const
Definition: map.H:278
MapKey< Key, Value > MapItem
Definition: map.H:36
HashMap(Cmp &&_cmp=Cmp(), HashFctPtr fct=&super_fast_hash)
Definition: map.H:581
HashFctType & get_hash_fct()
Definition: map.H:623
CmpWrapper(Cmp &&_cmp=Cmp())
Definition: map.H:112
CmpWrapper & operator=(const CmpWrapper &cw)
Definition: map.H:140
TreeMap(TreeMap &&map)
Definition: map.H:514
ArrayMap(Cmp &&_cmp=Cmp())
Definition: map.H:418
Value * search_or_insert(const Key &k)
Definition: map.H:326
HashMap(Cmp &_cmp, HashFctPtr _fct)
Definition: map.H:573
const Cmp & get_cmp() const
Definition: map.H:135
Value * append(Key &&k, const Value &v)
Definition: map.H:239
auto map_key(Args &&...args) -> decltype(std::make_pair(std::forward< Args >(args)...))
Definition: map.H:39
std::function< nat_t(const MapKey< Node< GT > *, Arc< GT > ** > &)> HashFctType
Definition: hash.H:88
ArrayMap(const std::initializer_list< Item > &l)
Definition: map.H:430
Cmp & get_cmp()
Definition: map.H:176
TreeMap(const std::initializer_list< Item > &l)
Definition: map.H:502
void swap(HashMap &map)
Definition: map.H:617
CmpWrapper(CmpWrapper &&cw)
Definition: map.H:124
CmpWrapper(const CmpWrapper &cw)
Definition: map.H:118
nat_t hash_fct_wrapper(Fct fct, const MapKey< Key, Value > &p)
Definition: map.H:537
bool has(const Key &k) const
Definition: map.H:360
const HashFctType & get_hash_fct() const
Definition: map.H:628
Cmp & get_cmp()
Definition: map.H:130
HashMap(const HashMap &map)
Definition: map.H:589
Value * append(Key &&k, Value &&v)
Definition: map.H:249
Value * search_or_insert(const Key &k, const Value &v)
Definition: map.H:302
Value * insert(const Key &k, Value &&v)
Definition: map.H:210
nat_t super_fast_hash(void *, nat_t)
Value * insert(Key &&k, const Value &v)
Definition: map.H:198
auto map_item(Args &&...args) -> decltype(std::make_pair(std::forward< Args >(args)...))
Definition: map.H:46
ArrayMap(ArrayMap &&map)
Definition: map.H:442
const Value & find(const Key &k) const
Definition: map.H:342
Key & key(MapKey< Key, Value > &item)
Definition: map.H:53
TreeMap(Cmp &_cmp)
Definition: map.H:484
ArrayMap(nat_t cap, Cmp &_cmp)
Definition: map.H:412
rng_t::result_type rng_seed_t
Definition: types.H:53
Value * insert(const Key &k, const Value &v)
Definition: map.H:186
Value * search_or_insert(const Key &k, Value &&v)
Definition: map.H:314
Value * insert(Key &&k, Value &&v)
Definition: map.H:222
std::pair< Key, Value > MapKey
Definition: map.H:33
const Value & find(Key &&k) const
Definition: map.H:354
Value * search_or_insert(Key &&k, const Value &v)
Definition: map.H:308
bool has(Key &&k) const
Definition: map.H:366
HashMap(nat_t size, Cmp &&_cmp=Cmp(), HashFctPtr fct=&super_fast_hash)
Definition: map.H:567
TreeMap(const TreeMap &map)
Definition: map.H:508
CmpWrapper(Cmp &_cmp)
Definition: map.H:106
nat_t SizeType
Definition: array.H:196
Value * search_or_insert(Key &&k)
Definition: map.H:331
HashMap(nat_t size, Cmp &_cmp, HashFctPtr _fct)
Definition: map.H:559
TreeMap(Cmp &&_cmp=Cmp())
Definition: map.H:490
unsigned long int nat_t
Definition: types.H:50
TreeMap(rng_seed_t seed, Cmp &_cmp)
Definition: map.H:478
bool operator()(const MapKey< Key, Value > &p, const MapKey< Key, Value > &q) const
Definition: map.H:155
Value & value(MapKey< Key, Value > &item)
Definition: map.H:77
Value * search(const Key &k)
Definition: map.H:254
HashMap(HashMap &&map)
Definition: map.H:595
Value * search(Key &&k)
Definition: map.H:266
ArrayMap(nat_t cap, Cmp &&_cmp=Cmp())
Definition: map.H:424
Value * append(const Key &k, const Value &v)
Definition: map.H:234
Value * search_or_insert(Key &&k, Value &&v)
Definition: map.H:320
Value & find(Key &&k)
Definition: map.H:348
const Value * search(Key &&k) const
Definition: map.H:290