← Back to team overview

kicad-developers team mailing list archive

Re: Cache algorithms

 

On Wed, Apr 22, 2015 at 10:06:09PM +0000, Mário Luzeiro wrote:
> Does anyone where have some implementation that maybe added to KiCad project?
> Or any suggestion where / how can I choose one to add?

An LRU cache can be implemented in different ways; boost suggest this:

http://www.boost.org/doc/libs/1_51_0/libs/multi_index/doc/examples.html#example9

Another way (the lispier one that I prefer) is to use an embedded list
structure backed by a set to index it: when you access an element you
cons it to the front, when you want to trim it you drop the tail. If the
list is sufficiently small it's actually faster to traverse the list
than maintain the set (also you don't need a d-list since you can keep
the prev pointer during the search traversal). 

-- 
Lorenzo Marcantonio
Logos Srl

Attachment: smime.p7s
Description: S/MIME cryptographic signature


Follow ups

References