Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
505:f59e4518fd57 | 507:c4122c3a47c1 |
---|---|
144 **/ | 144 **/ |
145 bool IsEmpty() const | 145 bool IsEmpty() const |
146 { | 146 { |
147 return index_.empty(); | 147 return index_.empty(); |
148 } | 148 } |
149 | |
150 const T& GetOldest() const; | |
151 | |
152 const Payload& GetOldestPayload() const; | |
149 }; | 153 }; |
150 | 154 |
151 | 155 |
152 | 156 |
153 | 157 |
245 | 249 |
246 CheckInvariants(); | 250 CheckInvariants(); |
247 | 251 |
248 return oldest; | 252 return oldest; |
249 } | 253 } |
254 | |
255 | |
256 template <typename T, typename Payload> | |
257 const T& LeastRecentlyUsedIndex<T, Payload>::GetOldest() const | |
258 { | |
259 if (IsEmpty()) | |
260 { | |
261 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
262 } | |
263 | |
264 return queue_.back().first; | |
265 } | |
266 | |
267 | |
268 template <typename T, typename Payload> | |
269 const Payload& LeastRecentlyUsedIndex<T, Payload>::GetOldestPayload() const | |
270 { | |
271 if (IsEmpty()) | |
272 { | |
273 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
274 } | |
275 | |
276 return queue_.back().second; | |
277 } | |
250 } | 278 } |