valsort_map.hpp

This file defines a map that is sorted by value, not key.

valsort_map is a limited implementation of map that also keeps track of the values set, in order, as you go. This is accomplished by keeping a second data structure, a sorted set, of all of the values maintained in the map.

The member functions cbegin() and cend() work as in map, but cvbegin() and cvend() produce the same set of results, except in value order. (reverse versions of each work as well)

Note

Status: ALPHA

template<class Key, class T>
class valsort_map
#include <valsort_map.hpp>

Public Types

using key_type = Key
using mapped_type = T
using value_type = std::pair<const Key, T>

Public Functions

inline valsort_map()
valsort_map(const valsort_map&) = default
valsort_map(valsort_map&&) = default
inline ~valsort_map()
inline size_t size() const
inline const mapped_type &Get(key_type key)
inline void Set(key_type key, const mapped_type &value)
inline auto cbegin()
inline auto cend()
inline auto crbegin()
inline auto crend()
inline auto cvbegin()
inline auto cvend()
inline auto crvbegin()
inline auto crvend()

Private Members

std::map<Key, T> item_map
std::set<value_type, SortOrder> val_set
struct SortOrder

Public Functions

inline bool operator()(const value_type &in1, const value_type &in2) const