How does one normally memoize properly in C?
Posted by Pinzonspiinzper@reddit | learnprogramming | View on Reddit | 3 comments
Do we keep a dynamic array holding the data we need or is there a more optimized, easier way of doing memoization in C?
nomoreplsthx@reddit
Depends on the use case. What's the structure of the data? What do you need to access it by? How much data? How long does it have to live? What kind of device are you running on? What algorithms will you execute on that data.
Cybasura@reddit
Cacheing in C, you would use a key-value mapping (Map/Hashmap/Dictionary/Tables) to map the data to a key if you need to cache it
So when you need to retrieve the data, instead of re-reading the file or reimport, just reference from the map
TallGirlKT@reddit
I would use a hashtable for holding the data.