18 #ifndef EMP_VALSORT_MAP_H 19 #define EMP_VALSORT_MAP_H 23 #include "../base/vector.h" 39 if (in1.second == in2.second)
return (in1.first < in2.first);
40 return in1.second < in2.second;
44 std::map<Key,T> item_map;
45 std::set< value_type, SortOrder > val_set;
53 size_t size()
const {
return item_map.size(); }
60 auto map_it = item_map.find(key);
61 if (map_it != item_map.end()) {
62 val_set.erase(*map_it);
63 map_it->second = value;
64 val_set.emplace(*map_it);
66 item_map[key] = value;
67 val_set.emplace(*item_map.find(key));
72 auto cbegin() {
return item_map.cbegin(); }
73 auto cend() {
return item_map.cend(); }
74 auto crbegin() {
return item_map.crbegin(); }
75 auto crend() {
return item_map.crend(); }
78 auto cvbegin() {
return val_set.cbegin(); }
79 auto cvend() {
return val_set.cend(); }
81 auto crvend() {
return val_set.crend(); }
auto crend()
Definition: valsort_map.h:75
Key key_type
Definition: valsort_map.h:33
void Set(key_type key, const mapped_type &value)
Definition: valsort_map.h:59
auto cend()
Definition: valsort_map.h:73
Definition: valsort_map.h:31
auto cvend()
Definition: valsort_map.h:79
valsort_map()
Definition: valsort_map.h:48
auto crbegin()
Definition: valsort_map.h:74
auto crvend()
Definition: valsort_map.h:81
T mapped_type
Definition: valsort_map.h:34
std::pair< const Key, T > value_type
Definition: valsort_map.h:35
If we are in emscripten, make sure to include the header.
Definition: array.h:37
const mapped_type & Get(key_type key)
Definition: valsort_map.h:55
~valsort_map()
Definition: valsort_map.h:51
auto cbegin()
Definition: valsort_map.h:72
size_t size() const
Definition: valsort_map.h:53
auto cvbegin()
Definition: valsort_map.h:78
auto crvbegin()
Definition: valsort_map.h:80