Possible Duplicate:
Is it there any LRU implementation of IDictionary?
I'm looking for a data structure that is like a dictionary but can only contain a set number of key value pairs. When a key value pair is added to a dictionary that is already full then a key value pair that hasn't been accessed recently would be removed.
Does anything like this already exist for C#?
I remember implementing something like this for an operating systems class and the data structure was used to decide which portion of RAM should be paged to disk. This was done by associating a reference bit with each key value pair which was set to true when the pair was accessed. When a pair needed to be removed the key values pairs would be iterated over until one was found with it's reference bit set to false. The reference bit of each pair iterated over would be set to false and the last one would be removed.
If a data structure for this doesn't already exist in C# then would the algorithm I described be a good way to implement it?