Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d8707c7 authored by John Reck's avatar John Reck
Browse files

Add a peekOldestValue

Change-Id: I89d8ea14c8ac02653d9c0e1fe24a4b17bb9c87f5
parent 391224c8
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ public:
    bool remove(const TKey& key);
    bool removeOldest();
    void clear();
    const TValue& peekOldestValue();

    class Iterator {
    public:
@@ -179,6 +180,14 @@ bool LruCache<TKey, TValue>::removeOldest() {
    return false;
}

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) {