When using linked-hash-map as a cache I'd like to mark possibly no-longer needed nodes as least recently used so that they will be the first to go. I will be making a simpler PR to lru-cache if this gets accepted.
Two commits, first renames the existing fn attach(..) to fn attach_next(..) which I think is suitable as the second commit adds an fn attach_prev(..) which will be invoked by mark_lru(..) together with fn detach(..).
Naming: the current API has pop_front and front for the last element in the list and lru is not exactly a term for linked-hash-map. I'm not sure which would be more suitable name, move_front, set_front, assign_front or perhaps mark_front?
Hi there,
When using
linked-hash-map
as a cache I'd like to mark possibly no-longer needed nodes as least recently used so that they will be the first to go. I will be making a simpler PR tolru-cache
if this gets accepted.Two commits, first renames the existing
fn attach(..)
tofn attach_next(..)
which I think is suitable as the second commit adds anfn attach_prev(..)
which will be invoked bymark_lru(..)
together withfn detach(..)
.Naming: the current API has
pop_front
andfront
for the last element in the list andlru
is not exactly a term for linked-hash-map. I'm not sure which would be more suitable name,move_front
,set_front
,assign_front
or perhapsmark_front
?