diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-02-12 17:07:39 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-02-12 17:07:39 +1100 |
| commit | 26df5c4a7f54d493a09724a5f4f8f4a3a5c90f31 (patch) | |
| tree | 168c313734ed388efa1847226d6cea61b8c0c7e0 /src/util/include | |
| parent | a7ac34eaa9b895e16aed816c504d167027898d7b (diff) | |
| download | tangara-fw-26df5c4a7f54d493a09724a5f4f8f4a3a5c90f31.tar.gz | |
Remember per-device bluetooth volume
Diffstat (limited to 'src/util/include')
| -rw-r--r-- | src/util/include/lru_cache.hpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/util/include/lru_cache.hpp b/src/util/include/lru_cache.hpp index 41293901..606a6387 100644 --- a/src/util/include/lru_cache.hpp +++ b/src/util/include/lru_cache.hpp @@ -10,9 +10,11 @@ #include <bitset> #include <cstdint> #include <list> +#include <map> #include <optional> #include <unordered_map> #include <utility> + #include "memory_resource.hpp" namespace util { @@ -64,9 +66,16 @@ class LruCache { key_to_it_.clear(); } + auto Get() const -> std::vector<std::pair<K, V>> { + std::vector<std::pair<K, V>> out; + out.resize(entries_.size()); + std::copy(entries_.begin(), entries_.end(), out.begin()); + return out; + } + private: std::pmr::list<std::pair<K, V>> entries_; - std::pmr::unordered_map<K, decltype(entries_.begin())> key_to_it_; + std::pmr::map<K, decltype(entries_.begin())> key_to_it_; }; } // namespace util |
