Skip to content

Commit

Permalink
Add lru.keys iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
Menduist committed Apr 7, 2022
1 parent 717abe4 commit 8767ade
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lrucache.nim
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,9 @@ proc removeLru*[K,T](cache: LruCache[K,T]): T
# under no circumstances should `val` be Option.none, given that the cache is
# not empty, we should always have an LRU key
return val.get

iterator keys*[K,T](cache: LruCache[K,T]): lent K =
var it = cache.list.head
while not isNil(it):
yield it.value.key
it = it.next

0 comments on commit 8767ade

Please sign in to comment.