Skip to content

Commit

Permalink
Name the Priority type parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
asayers committed Feb 24, 2015
1 parent 3ef0584 commit 9ac64f5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions posts/2015-02-18-lru-cache.lhs
Expand Up @@ -49,15 +49,17 @@ over `k` and `v`. The types represent our key and value respectively. We will
use the `k` and `v` as key value types in our priority search queue `cQueue`,
and as priority we are using an `Int64`.

> type Priority = Int64

The `cTick` field represents a simple logical time value, and the next item we
insert will have this priority -- this means that another invariant of our code
is that all priorities in `cQueue` are smaller than `cTick`.

> data Cache k v = Cache
> { cCapacity :: !Int
> , cSize :: !Int
> , cTick :: !Int64
> , cQueue :: !(HashPSQ.HashPSQ k Int64 v)
> , cTick :: !Priority
> , cQueue :: !(HashPSQ.HashPSQ k Priority v)
> }

Creating an empty `Cache` is easy; we just need to know the maximum capacity.
Expand Down

0 comments on commit 9ac64f5

Please sign in to comment.