Mercurial > hg > orthanc
diff Core/Cache/LeastRecentlyUsedIndex.h @ 507:c4122c3a47c1
access to oldest item in LRUCache
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 16 Aug 2013 10:24:49 +0200 |
parents | f59e4518fd57 |
children | e7841864c97c |
line wrap: on
line diff
--- a/Core/Cache/LeastRecentlyUsedIndex.h Fri Aug 16 10:17:45 2013 +0200 +++ b/Core/Cache/LeastRecentlyUsedIndex.h Fri Aug 16 10:24:49 2013 +0200 @@ -146,6 +146,10 @@ { return index_.empty(); } + + const T& GetOldest() const; + + const Payload& GetOldestPayload() const; }; @@ -247,4 +251,28 @@ return oldest; } + + + template <typename T, typename Payload> + const T& LeastRecentlyUsedIndex<T, Payload>::GetOldest() const + { + if (IsEmpty()) + { + throw OrthancException(ErrorCode_BadSequenceOfCalls); + } + + return queue_.back().first; + } + + + template <typename T, typename Payload> + const Payload& LeastRecentlyUsedIndex<T, Payload>::GetOldestPayload() const + { + if (IsEmpty()) + { + throw OrthancException(ErrorCode_BadSequenceOfCalls); + } + + return queue_.back().second; + } }