From eb8969b433df4c4a43968480966d687e34e35866 Mon Sep 17 00:00:00 2001 From: Nils-Erik Frantzell Date: Mon, 29 Jul 2019 20:17:18 -0700 Subject: [PATCH] Reorder functions in LruCache header --- libdevcore/LruCache.h | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/libdevcore/LruCache.h b/libdevcore/LruCache.h index 9eeff1a8404..1cdef0d5ae5 100644 --- a/libdevcore/LruCache.h +++ b/libdevcore/LruCache.h @@ -19,6 +19,7 @@ class LruCache public: explicit LruCache(size_t _capacity) : m_capacity(_capacity) {} + LruCache(LruCache const& _l) { m_capacity = _l.m_capacity; @@ -51,26 +52,6 @@ class LruCache return *this; } - bool contains(key_type const& _key) const { return m_index.find(_key) != m_index.cend(); } - - bool contains(key_type const& _key, value_type const& _value) const - { - auto const cIter = m_index.find(_key); - return cIter != m_index.cend() && (*(cIter->second)).second == _value; - } - - typename list_type::const_iterator cbegin() const { return m_data.cbegin(); } - - typename list_type::iterator begin() { return m_data.begin(); } - - typename list_type::const_iterator cend() const { return m_data.cend(); } - - typename list_type::iterator end() { return m_data.end(); } - - size_t size() const { return m_index.size(); } - - bool empty() const { return m_index.empty(); } - size_t insert(key_type const& _key, value_type const& _val) { auto const cIter = m_index.find(_key); @@ -104,8 +85,6 @@ class LruCache return m_index.size(); } - size_t capacity() const { return m_capacity; } - bool touch(key_type const& _key) { auto const cIter = m_index.find(_key); @@ -117,12 +96,32 @@ class LruCache return false; } + bool contains(key_type const& _key) const { return m_index.find(_key) != m_index.cend(); } + + bool contains(key_type const& _key, value_type const& _value) const + { + auto const cIter = m_index.find(_key); + return cIter != m_index.cend() && (*(cIter->second)).second == _value; + } + + bool empty() const { return m_index.empty(); } + + size_t size() const { return m_index.size(); } + + size_t capacity() const { return m_capacity; } + void clear() { m_index.clear(); m_data.clear(); } + // Expose data iterator for testing purposes + typename list_type::const_iterator cbegin() const { return m_data.cbegin(); } + typename list_type::iterator begin() { return m_data.begin(); } + typename list_type::const_iterator cend() const { return m_data.cend(); } + typename list_type::iterator end() { return m_data.end(); } + private: list_type m_data; map_type m_index;