From f2d33114f7c5a91a6b6f5760d5f84b40294cc6e1 Mon Sep 17 00:00:00 2001 From: yperbasis Date: Wed, 29 Jul 2020 14:52:42 +0200 Subject: [PATCH] Add clear() and mark size() noexcept --- include/lrucache.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/lrucache.hpp b/include/lrucache.hpp index 9e5e285..17ef43f 100644 --- a/include/lrucache.hpp +++ b/include/lrucache.hpp @@ -56,10 +56,15 @@ class lru_cache { return _cache_items_map.find(key) != _cache_items_map.end(); } - size_t size() const { + size_t size() const noexcept { return _cache_items_map.size(); } + void clear() noexcept { + _cache_items_map.clear(); + _cache_items_list.clear(); + } + private: std::list _cache_items_list; std::unordered_map _cache_items_map;