#ifndef _2Q_CACHE_H_ #define _2Q_CACHE_H_ #include #include #include class TwoCache { private: //2 LRU caches size_t cpct_q1; std::unordered_map::iterator> umap1; std::list q1; //fast queue - the most popular pages size_t cpct_q2; std::unordered_map::iterator> umap2; std::list q2; //slow queue - if page asked at the first time put it to q2, if itasked from q2 it put it to q1, public: TwoCache(size_t q1sz, size_t q2sz): cpct_q1(q1sz), cpct_q2(q2sz) {} //ctor void put_page(int id) { std::cout << "id: " << id << std::endl; //std::cout <<__LINE__ << " " << __FILE__<< std::endl; if (umap1.find(id) != umap1.end()) { //page is found, nothing to do (fast case) std::cout << "id ="<first) << ", Val: " << *(it->second) << " "; } std::cout << std::endl; std::cout << "Umap2:\n"; for (auto it = umap2.begin(); it != umap2.end(); ++it) { std::cout << "Key: " << it->first << ", Val: " << *(it->second) << " "; } std::cout << std::endl<