Subj : Re: best data structure for LRU cache? To : comp.programming From : Jon Harrop Date : Tue Aug 09 2005 01:43 pm Willem wrote: > Jon wrote: > ) Alex Fraser wrote: > )> "Jon Harrop" wrote in message > )> news:42f66c04$0$24029$ed2619ec@ptn-nntp-reader01.plus.net... > )>> I've never done this before, but in the simplest case I think you can > )>> just use an int index into an array. The int points to the oldest > entry. )>> To insert you overwrite the array entry at the int before > incrementing )>> it. To search, consider each entry in turn. > )> > )> You are taking the piss, right? > ) > ) What do you think is wrong with that? > > You can't remove items from the middle of the cache this way. I can't think why not, it just isn't fast. My point was simply that you don't need to use balanced binary trees or hash tables if you don't mind a slow solution. -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com .