aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-pdf/lrucache.h
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2019-04-03 15:21:17 -0400
committerKen Moore <ken@ixsystems.com>2019-04-03 15:21:17 -0400
commit8d5f1e04d7e4f24a4026804d62abe64883419bf2 (patch)
treee8de5a663e7c39db7979b61320a220bcbbdfa5ce /src-qt5/desktop-utils/lumina-pdf/lrucache.h
parentUpdate README.md (diff)
downloadlumina-8d5f1e04d7e4f24a4026804d62abe64883419bf2.tar.gz
lumina-8d5f1e04d7e4f24a4026804d62abe64883419bf2.tar.bz2
lumina-8d5f1e04d7e4f24a4026804d62abe64883419bf2.zip
Remove lumina-calculator and lumina-pdf from the lumina repo.
They have their own repos now (https://github.com/lumina-desktop/lumina-[pdf/calculator])
Diffstat (limited to 'src-qt5/desktop-utils/lumina-pdf/lrucache.h')
-rw-r--r--src-qt5/desktop-utils/lumina-pdf/lrucache.h60
1 files changed, 0 insertions, 60 deletions
diff --git a/src-qt5/desktop-utils/lumina-pdf/lrucache.h b/src-qt5/desktop-utils/lumina-pdf/lrucache.h
deleted file mode 100644
index 0ed241c2..00000000
--- a/src-qt5/desktop-utils/lumina-pdf/lrucache.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef LUMINA_PDF_LRUCACHE_H
-#define LUMINA_PDF_LRUCACHE_H
-
-#include <list>
-#include <optional>
-#include <tuple>
-#include <unordered_map>
-
-namespace LuminaPDF {
-template <class Value, class Key = int> class LRUCache {
-public:
- LRUCache() = default;
- ~LRUCache() = default;
-
- void setCacheSize(size_t _max) {
- max = _max;
- hashmap.reserve(max);
- return;
- }
-
- std::optional<Value> get(const Key k) {
- auto itr = hashmap.find(k);
-
- if (itr == hashmap.end()) {
- return std::nullopt;
- }
-
- Value v = std::get<1>(*std::get<1>(*itr));
-
- values.erase(std::get<1>(*itr));
- values.push_front(std::make_tuple(k, v));
- hashmap[k] = values.begin();
- return v;
- }
-
- void push(const Key k, const Value v) {
- while (hashmap.size() >= max) {
- Key _k = std::get<0>(values.back());
- values.pop_back();
- hashmap.erase(_k);
- }
-
- values.push_front(std::make_tuple(k, v));
- hashmap[k] = values.begin();
- }
-
- bool contains(const Key k){
- auto itr = hashmap.find(k);
- return ( itr!=hashmap.end() );
- }
-
-private:
- size_t max;
- std::list<std::tuple<Key, Value>> values;
- std::unordered_map<Key, typename std::list<std::tuple<Key, Value>>::iterator>
- hashmap;
-};
-} // namespace LuminaPDF
-
-#endif // LUIMINA_PDF_LRUCACHE_H
bgstack15