Created
November 13, 2012 15:18
-
-
Save MikeBild/4066272 to your computer and use it in GitHub Desktop.
Tiny LRU cache implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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