43 public static T
Add(T item) => Entries.
Add(item).
Item;
46 public static T
Value(
object nodeReference) {
48 return (node == null) ? default : node.Item;
52 public static void Dispose(T item) => Entries.Dispose(item);
55 public static void RecycleEverything() => Entries.Dispose();
58 public static Func<T>
CreateItem {
set => Entries.CreateItem = value; }
61 public static Action<T>
DeactivateItem {
set => Entries.DeactivateItem = (node) => value(node.Item); }
64 public static Action<T>
ReactivateItem {
set => Entries.ReactivateItem = (node) => value(node.Item); }
67 public static IDisposable
Disposable(T item) =>
new Disposable {Action = Entries.ReverseLookup(item).Dispose};
Node GetRecycledOrNew()
Get a node and item either recycled or created new.
static T Instance
Get a node reference (from recycling if available)
static Action< T > ReactivateItem
A lambda to be called before reusing an item from the recycle bin
static Func< T > CreateItem
A lambda to be called to create an item
static Boxed New(T item)
Add a cache entry containing a new value item
static LinkedList< T >.Node NodeInstance
Get a node reference (from recycling if available)
override string ToString()
LinkedList - a different perspective
Node GetRecycledOrNew()
Retrieve a node - either from recycling or creating it anew
static T Instance
//#TBD#//
static Boxed Clone(Boxed< T > item)
Create a new cache holding a copy of the value item.
static T Value(object nodeReference)
//#TBD#//
static T Add(T item)
Get a new or recycled node and add an item reference
Node Add(T t)
Fetch an unused node and use it as the container for the provided new item
T Value
Unboxed value storage
static Action< T > DeactivateItem
A lambda to be called before sending an item to recycling for later use
T Item
Item can be value type (int, float ... struct) or object (class instance)
Simplified creation of an action that happens at the end of a using statement no matter what else hap...
static readonly LinkedList< T > Entries
A Cache is managed as a linked list of entries