Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class web_server
- {
- int limit ;
- list < string > history;
- unordered_map < string, list < string > :: iterator > website_pointer;
- // std::priority_queue<int, std::vector<int>, std::greater<int> > my_min_heap;
- priorety_queu <pair <int , string>, vector <pair <int , string>, greater<int> > top_five;
- unordered_map < string, int > inside_queu;
- public:
- web_server (int capacity)
- {
- limit = capacity;
- }
- void visit (string site)
- {
- update_top_five(site);
- update_history (site);
- }
- void update_history (string site)
- {
- if (history.size() == limit && website_pointer.count(site) == 0 )
- {
- string name_del = history.back();
- history.pop_back();
- website_pointer.erase(name_del);
- }
- if (website_pointer.count(site) > 0)
- {
- list < string > :: iterator pointer_del = website_pointer[site];
- website_pointer.erase(site);
- history.erase(pointer_del);
- }
- history.push_front(site);
- website_pointer[site] = history.begin();
- }
- list <string> get_history()
- {
- return history;
- }
- };
- /*
- list of web_sites
- unordeed_map < web_sites, addres_list>
- */
- int main() {
- std::cout << "Hello World!\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement