summaryrefslogtreecommitdiffstats
path: root/include/utils
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-04-11 19:14:15 -0700
committerJohn Reck <jreck@google.com>2014-04-11 19:14:15 -0700
commit9d8707c75aba22c637bb0f9d61f5126fc55816df (patch)
tree5e24e405ab93da986affdeb3a36b1531b244fe4d /include/utils
parent391224c807d2e28e55817b53ff3a30e57d08e996 (diff)
downloadsystem_core-9d8707c75aba22c637bb0f9d61f5126fc55816df.zip
system_core-9d8707c75aba22c637bb0f9d61f5126fc55816df.tar.gz
system_core-9d8707c75aba22c637bb0f9d61f5126fc55816df.tar.bz2
Add a peekOldestValue
Change-Id: I89d8ea14c8ac02653d9c0e1fe24a4b17bb9c87f5
Diffstat (limited to 'include/utils')
-rw-r--r--include/utils/LruCache.h9
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) {