Search for a data structure (list) that tracks "frequency of use",

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.

+7
c # algorithm data-structures
source share

No one has answered this question yet.

See similar questions:

27
Is there any LRU implementation for IDRU?
4
LFU cache in C #?

or similar:

797
What are less known but useful data structures?
438
Java tree data structure?
285
What are the main data structures used for Redis?
206
Tree data structure in C #
182
.NET Data Structures: ArrayList, List, HashTable, Dictionary, SortedList, SortedDictionary - Speed, memory and when to use them?
107
Search Algorithm Top 10 Search Queries
eleven
F # Continuous data structures for real-time high-frequency data streams
10
Ordered list with random access and deletion O (1)
5
How to prove a lower bound logarithm for a data structure?
3
efficient memory structure to track a subset of an array in source order

All Articles