Click here to Skip to main content
15,887,596 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
RickZeeland24-Sep-22 7:13
mveRickZeeland24-Sep-22 7:13 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
Greg Utas24-Sep-22 7:24
professionalGreg Utas24-Sep-22 7:24 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
honey the codewitch24-Sep-22 9:03
mvahoney the codewitch24-Sep-22 9:03 
JokeRe: "Use C!" they said. "It will be fun!", they said Pin
Randor 24-Sep-22 12:48
professional Randor 24-Sep-22 12:48 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
Eddy Vluggen24-Sep-22 9:20
professionalEddy Vluggen24-Sep-22 9:20 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
Daniel Pfeffer24-Sep-22 10:44
professionalDaniel Pfeffer24-Sep-22 10:44 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
honey the codewitch24-Sep-22 10:46
mvahoney the codewitch24-Sep-22 10:46 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
Daniel Pfeffer24-Sep-22 13:38
professionalDaniel Pfeffer24-Sep-22 13:38 
You have two problems here, which should ideally be solved using two mechanisms. Note that an object's handle won't work as an LRU timestamp because it is fixed, and an LRU timestamp won't work as an object's handle because it is subject to change.

The LRU cache maintenance can most easily be performed using a doubly-linked list. This is only one more word per cache node than is used for your timestamp method, is easy to implement, and is extremely fast.

Searching the cache is a separate problem. A red-black tree sorted by the objects' handles would solve this problem nicely.

If memory constraints prevent you from implementing both LRU and search mechanisms, you will have to fall back to a linear search for one of the operations.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.

GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
honey the codewitch24-Sep-22 15:10
mvahoney the codewitch24-Sep-22 15:10 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
Randor 24-Sep-22 15:33
professional Randor 24-Sep-22 15:33 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
honey the codewitch24-Sep-22 15:51
mvahoney the codewitch24-Sep-22 15:51 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
Randor 24-Sep-22 16:44
professional Randor 24-Sep-22 16:44 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
honey the codewitch24-Sep-22 16:46
mvahoney the codewitch24-Sep-22 16:46 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
Randor 24-Sep-22 17:15
professional Randor 24-Sep-22 17:15 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
honey the codewitch24-Sep-22 17:34
mvahoney the codewitch24-Sep-22 17:34 
PraiseRe: "Use C!" they said. "It will be fun!", they said Pin
Randor 24-Sep-22 17:44
professional Randor 24-Sep-22 17:44 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
honey the codewitch24-Sep-22 17:58
mvahoney the codewitch24-Sep-22 17:58 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
jmaida24-Sep-22 11:08
jmaida24-Sep-22 11:08 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
englebart26-Sep-22 14:39
professionalenglebart26-Sep-22 14:39 
GeneralRe: "Use C!" they said. "It will be fun!", they said Pin
honey the codewitch26-Sep-22 15:08
mvahoney the codewitch26-Sep-22 15:08 
GeneralState of the world - getting kicked in the teeth! X( Pin
honey the codewitch23-Sep-22 22:25
mvahoney the codewitch23-Sep-22 22:25 
GeneralRe: State of the world - getting kicked in the teeth! X( Pin
RickZeeland23-Sep-22 23:21
mveRickZeeland23-Sep-22 23:21 
GeneralRe: State of the world - getting kicked in the teeth! X( Pin
Daniel Pfeffer24-Sep-22 7:47
professionalDaniel Pfeffer24-Sep-22 7:47 
GeneralRe: State of the world - getting kicked in the teeth! X( Pin
honey the codewitch24-Sep-22 9:03
mvahoney the codewitch24-Sep-22 9:03 
GeneralRe: State of the world - getting kicked in the teeth! X( Pin
englebart26-Sep-22 14:44
professionalenglebart26-Sep-22 14:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.