Apologize in advance for the poor wording and difficult question, English is the second language.
I am looking for a data structure to store an array / list / collection of objects (in my case, integer identifiers, but that doesn't matter) that will track the "frequency of use" of the elements . Therefore, I can run the background task and remove the less used items (to free up memory usage).
Something like when an element is available or looking for - the element moves "to the surface", pushing the less used elements "to the bottom". Again, the goal is to determine the βless accessible accessβ values ββand to delete them from time to time.
I was thinking of writing my own class, inheriting / subclassing the existing list structure ( LinkedList<T,T> or Queue<T> possible), and then overloading some GetElement method so that it "returns" the item And move it to the top of the list " Therefore, later in my background task, I can remove items from the "end of the list" (for example, they are accessed less frequently).
- Am I in the right direction?
- Is there a built-in data structure in .NET for this or some well-known practice? I tried to walk, found nothing. But I'm sure this problem is as old as the history of computing :)
Thanks!
UPDATE: thanks for the comments. It turns out that "LRU" is what he called in plain English. I close this question because the search engine for the "LRU C # cache" offers a ton of answers.
jazzcat
source share