MCPcopy Create free account
hub / github.com/computationalpathologygroup/ASAP / set

Method set

ASAP/WSITileGraphicsItemCache.cpp:56–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56int WSITileGraphicsItemCache::set(const keyType& k, WSITileGraphicsItem* v, unsigned int size, bool topLevel) {
57 if (_cache.find(k) != _cache.end()) {
58 return 1;
59 }
60 if (size > _cacheMaxByteSize) {
61 return 1;
62 }
63 while (_cacheCurrentByteSize + size > _cacheMaxByteSize && _cacheCurrentByteSize != 0) {
64 evict();
65 }
66
67 // Do not add to the LRU if it is a top-level item so it is never removed
68 if (!topLevel) {
69 keyTypeList::iterator it = _LRU.insert(_LRU.end(), k);
70 _cache[k] = std::make_pair(std::make_pair(v, size), it);
71 }
72 else {
73 _cache[k] = std::make_pair(std::make_pair(v, size), _LRU.end());
74 }
75 _cacheCurrentByteSize += size;
76 return 0;
77}

Callers 1

onTileLoadedMethod · 0.45

Calls 1

insertMethod · 0.80

Tested by

no test coverage detected