BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
BioImager.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)
 

Detailed Description

Definition at line 13 of file ISlideSource.cs.

Constructor & Destructor Documentation

◆ LruCache()

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

Definition at line 24 of file ISlideSource.cs.

25 {
26 this.capacity = capacity;
27 }

Member Function Documentation

◆ Add()

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

Definition at line 44 of file ISlideSource.cs.

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

◆ Get()

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

Definition at line 29 of file ISlideSource.cs.

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

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