diff options
author | John Reck <jreck@google.com> | 2014-04-14 20:17:53 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-04-14 20:17:53 +0000 |
commit | 8af196c1f5f9f8133384df8607f7addbaa697a42 (patch) | |
tree | 1e9a2bc69c6d18d593c8cef65886f8bb1f6f06cd /include | |
parent | 8d56ff5d12548ac463877fa8dc3554d02a145f97 (diff) | |
parent | 9d8707c75aba22c637bb0f9d61f5126fc55816df (diff) | |
download | system_core-8af196c1f5f9f8133384df8607f7addbaa697a42.zip system_core-8af196c1f5f9f8133384df8607f7addbaa697a42.tar.gz system_core-8af196c1f5f9f8133384df8607f7addbaa697a42.tar.bz2 |
Merge "Add a peekOldestValue"
Diffstat (limited to 'include')
-rw-r--r-- | include/utils/LruCache.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/utils/LruCache.h b/include/utils/LruCache.h index fa8f03f..f615a32 100644 --- a/include/utils/LruCache.h +++ b/include/utils/LruCache.h @@ -48,6 +48,7 @@ public: bool remove(const TKey& key); bool removeOldest(); void clear(); + const TValue& peekOldestValue(); class Iterator { public: @@ -180,6 +181,14 @@ bool LruCache<TKey, TValue>::removeOldest() { } template <typename TKey, typename TValue> +const TValue& LruCache<TKey, TValue>::peekOldestValue() { + if (mOldest) { + return mOldest->value; + } + return mNullValue; +} + +template <typename TKey, typename TValue> void LruCache<TKey, TValue>::clear() { if (mListener) { for (Entry* p = mOldest; p != NULL; p = p->child) { |