Skip to content

Instantly share code, notes, and snippets.

@MikeBild
Created November 13, 2012 15:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeBild/4066272 to your computer and use it in GitHub Desktop.
Save MikeBild/4066272 to your computer and use it in GitHub Desktop.
Tiny LRU cache implementation
public class LRUObservableCollection<T> : ObservableCollection<T>
{
private readonly int _length;
public LRUObservableCollection(int length)
{
_length = length;
}
protected override void InsertItem(int index, T item)
{
base.InsertItem(index, item);
if (Count > _length) RemoveAt(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment