fork download
  1. #include <set>
  2. #include <map>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. struct comp {
  8. bool operator ()(const pair<int, int>& a, const pair<int, int>& b) const {
  9. return a.second < b.second;
  10. }
  11. };
  12. typedef set<pair<int, int>, comp> S;
  13.  
  14. struct LRUCache {
  15. S cache;
  16. typedef S::iterator it;
  17. int cap;
  18.  
  19. LRUCache(int capacity) {
  20. cap = capacity;
  21. }
  22.  
  23. int get(int key) {
  24.  
  25. }
  26.  
  27. void setC(int key, int value) {
  28. cache.insert({key, value});
  29. }
  30.  
  31. void initialize() {
  32. vector<int> temp{ 5,20,35,20,83,17,5,1,0,239,242,42 };
  33. for (int i = 0; i < temp.size(); i++) {
  34. setC(i, temp[i]);
  35.  
  36. }
  37. }
  38.  
  39. };
  40.  
  41. int main()
  42. {
  43. LRUCache test(5);
  44. test.initialize();
  45. test.setC(1, 5);
  46. test.setC(12, 20);
  47. return 0;
  48. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty