BioLib  3.6.2
A GUI-less version of Bio .NET library for editing & annotating various microscopy image formats.
Loading...
Searching...
No Matches
BioLib.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 ()
 

Detailed Description

Definition at line 15 of file ISlideSource.cs.

Constructor & Destructor Documentation

◆ LruCache()

BioLib.LruCache< TileInformation, TValue >.LruCache ( int capacity)

Definition at line 26 of file ISlideSource.cs.

27 {
28 this.capacity = capacity;
29 }

Member Function Documentation

◆ Add()

void BioLib.LruCache< TileInformation, TValue >.Add ( Info key,
TValue value )

Definition at line 46 of file ISlideSource.cs.

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 BioLib.LruCache< TileInformation, TValue >.Dispose ( )

Definition at line 67 of file ISlideSource.cs.

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

◆ Get()

TValue BioLib.LruCache< TileInformation, TValue >.Get ( Info key)

Definition at line 31 of file ISlideSource.cs.

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: