PeanutButter
|
Holds a list of most-recently-used items, up to the provided capacity. New items displace the older ones, and re-adding the same item will reposition that item at the top of the list. More...
Public Member Functions | |
MostRecentlyUsedList (int capacity) | |
Holds a list of most-recently-used items, up to the provided capacity. New items displace the older ones, and re-adding the same item (test is via .Equals) will reposition that item at the top of the list. | |
void | Add (T item) |
Adds an item to the collection. If the capacity of the collection is exceeded, the last-used value will be evicted. | |
bool | Contains (T item) |
Tests if the provided item is in the list. | |
IEnumerator< T > | GetEnumerator () |
Properties | |
int | Capacity [get] |
The capacity of this list. Once this is reached, adding new items will evict older ones. |
Holds a list of most-recently-used items, up to the provided capacity. New items displace the older ones, and re-adding the same item will reposition that item at the top of the list.
Object equality testing is via .GetHashCode(), for performance reasons - so primitives will "just work", but your own types will require you to implement .GetHashCode() (and .Equals() for completeness' sake) so that the internal dictionary can properly index by the object)
MostRecentlyUsedList<T> is not thread-safe: if you plan on accessing this (read or write) from multiple threads, you must lock it yourself.
T |
void PeanutButter.Utils.MostRecentlyUsedList< T >.Add | ( | T | item | ) |
Adds an item to the collection. If the capacity of the collection is exceeded, the last-used value will be evicted.
item |
bool PeanutButter.Utils.MostRecentlyUsedList< T >.Contains | ( | T | item | ) |
Tests if the provided item is in the list.
item |