aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/map.h
blob: a43c8eca4eed0ed58994a07551b072be9449c3db (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once

#include "fwd.h"
#include "mapfindptr.h"

#include <util/str_stl.h>
#include <util/memory/alloc.h>

#include <utility>
#include <initializer_list>
#include <map>
#include <memory>

template <class K, class V, class Less, class A>
class TMap: public std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>, public TMapOps<TMap<K, V, Less, A>> {
    using TBase = std::map<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>; 

public:
    using TBase::TBase;

    inline explicit operator bool() const noexcept {
        return !this->empty();
    }

    inline bool contains(const K& key) const {
        return this->find(key) != this->end();
    }
};

template <class K, class V, class Less, class A>
class TMultiMap: public std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>> {
    using TBase = std::multimap<K, V, Less, TReboundAllocator<A, std::pair<const K, V>>>; 

public:
    using TBase::TBase;

    inline explicit operator bool() const noexcept {
        return !this->empty();
    }

    inline bool contains(const K& key) const {
        return this->find(key) != this->end();
    }
};