BioGTK  5.1.1
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images.
Loading...
Searching...
No Matches
Bio.LruCache< TileInformation, TValue > Class Template Reference

Classes

class  Info
 

Public Member Functions

 LruCache (int capacity)
 
TValue Get (Info key)
 
void Add (Info key, TValue value)
 
void Dispose ()
 

Constructor & Destructor Documentation

◆ LruCache()

Bio.LruCache< TileInformation, TValue >.LruCache ( int  capacity)
inline
27 {
28 this.capacity = capacity;
29 }

Member Function Documentation

◆ Add()

void Bio.LruCache< TileInformation, TValue >.Add ( Info  key,
TValue  value 
)
inline
47 {
48 if (cacheMap.Count >= capacity)
49 {
50 var oldest = lruList.First;
51 if (oldest != null)
52 {
53 lruList.RemoveFirst();
54 cacheMap.Remove(oldest.Value.key);
55 }
56 }
57
58 if (cacheMap.ContainsKey(key))
59 {
60 lruList.Remove(cacheMap[key]);
61 }
62
63 var newNode = new LinkedListNode<(Info key, TValue value)>((key, value));
64 lruList.AddLast(newNode);
65 cacheMap[key] = newNode;
66 }

◆ Dispose()

void Bio.LruCache< TileInformation, TValue >.Dispose ( )
inline
68 {
69 foreach (LinkedListNode<(Info key, TValue value)> item in cacheMap.Values)
70 {
71 lruList.Remove(item);
72 }
73 }

◆ Get()

TValue Bio.LruCache< TileInformation, TValue >.Get ( Info  key)
inline
32 {
33 foreach (LinkedListNode<(Info key, TValue value)> item in cacheMap.Values)
34 {
35 Info k = item.Value.key;
36 if(k.Coordinate == key.Coordinate && k.Index == key.Index)
37 {
38 lruList.Remove(item);
39 lruList.AddLast(item);
40 return item.Value.value;
41 }
42 }
43 return default(TValue);
44 }

The documentation for this class was generated from the following file: