I don't know what data structure to use for this problem. I want the structure to have:
- Constant time insertion or deletion.
- Constant time retrieval by id.
The actual system is:
I've got a bunch of objects each with a unique id. My program will need to receive requests for an id and return the relevant object.
Whenever it receives a request I want it to: search the structure to see if it's there. If it is, return it. If it isn't, load it from the disk into memory (put it in the structure so that next time it is requested it doesn't have to use the disk) and then return it.
I'm using C.
Here's a similar question but I'm not sure how relevant it is.