Fixed Size Caching Structure C#

Viewed 341

Is there a built in LIFO collection that upon reaching a certain size, if another item is added it drops the item at the "bottom of the stack" (for want of a better way to describe it).

For instance, say I define the size to be 10 and I add some items so my "stack" looks something like this:

top
j
i
h
g
f
e
d
c
b
a
bottom

And then I push 'k' onto the top, 'a' would drop out of the bottom of the collection and be consigned to gc.

I'm sure I could implement similar functionality myself, but for the sake of not reinventing the wheel I'm wondering if any .NET or C# collection implements similar functionality?

Ideally I'd like for it to be a generic collection rather than just working with objects.

0 Answers
Related