From 4c55e5257f60a5a1c0420d706c8312693499d474 Mon Sep 17 00:00:00 2001 From: realstealthninja Date: Tue, 22 Oct 2024 14:06:47 +0000 Subject: [PATCH] Documentation for ffef54470dededc7cc82cffb930432c110f7c46a --- annotated.html | 1 + annotated_dup.js | 3 +- classes.html | 2 +- ...ers_1_1_cache_1_1_l_r_u_cache-members.html | 136 ++++ ...1_1_cache_1_1_l_r_u_cache__coll__graph.map | 13 + ...1_1_cache_1_1_l_r_u_cache__coll__graph.md5 | 1 + ...1_1_cache_1_1_l_r_u_cache__coll__graph.svg | 205 ++++++ ...cache_1_1_l_r_u_cache__coll__graph_org.svg | 122 ++++ d4/d89/lru__cache2_8cpp__incl.map | 11 + d4/d89/lru__cache2_8cpp__incl.md5 | 1 + d4/d89/lru__cache2_8cpp__incl.svg | 119 ++++ d4/d89/lru__cache2_8cpp__incl_org.svg | 93 +++ ...others_1_1_cache_1_1_d___node-members.html | 7 +- ...classothers_1_1_cache_1_1_l_r_u_cache.html | 651 ++++++++++++++++++ .../classothers_1_1_cache_1_1_l_r_u_cache.js | 17 + ...ee34fcee480f21bb6f68a34f0f69b45_cgraph.map | 10 + ...ee34fcee480f21bb6f68a34f0f69b45_cgraph.md5 | 1 + ...ee34fcee480f21bb6f68a34f0f69b45_cgraph.svg | 113 +++ ...fcee480f21bb6f68a34f0f69b45_cgraph_org.svg | 87 +++ ...1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.map | 7 + ...1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.md5 | 1 + ...1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.svg | 85 +++ ...357ecc7c34144f3d9a63c6cb3ea_cgraph_org.svg | 59 ++ ...022d494b40f82417340b113445e79a4_cgraph.map | 5 + ...022d494b40f82417340b113445e79a4_cgraph.md5 | 1 + ...022d494b40f82417340b113445e79a4_cgraph.svg | 67 ++ ...494b40f82417340b113445e79a4_cgraph_org.svg | 41 ++ db/dde/namespaceothers_1_1_cache.html | 3 + db/dde/namespaceothers_1_1_cache.js | 3 +- dc/daa/lru__cache2_8cpp.html | 288 ++++++++ dc/daa/lru__cache2_8cpp.js | 7 + ...8dca7b867074164d5f45b0f3851269d_cgraph.map | 23 + ...8dca7b867074164d5f45b0f3851269d_cgraph.md5 | 1 + ...8dca7b867074164d5f45b0f3851269d_cgraph.svg | 291 ++++++++ ...7b867074164d5f45b0f3851269d_cgraph_org.svg | 208 ++++++ ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map | 25 + ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 | 1 + ...66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg | 309 +++++++++ ...b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg | 226 ++++++ .../classothers_1_1_cache_1_1_d___node.html | 53 +- de/d21/classothers_1_1_cache_1_1_d___node.js | 4 +- dir_9510827d0b234b3cc54b29892f217477.html | 3 + dir_9510827d0b234b3cc54b29892f217477.js | 1 + doxygen_crawl.html | 25 +- files.html | 27 +- functions.html | 2 +- functions_c.html | 2 +- functions_e.html | 2 +- functions_func_c.html | 2 +- functions_func_e.html | 2 +- functions_func_g.html | 2 +- functions_func_l.html | 2 +- functions_func_m.html | 1 + functions_func_p.html | 5 +- functions_func_s.html | 2 +- functions_func_~.html | 1 + functions_g.html | 2 +- functions_h.html | 2 +- functions_l.html | 2 +- functions_m.html | 1 + functions_n.html | 4 +- functions_p.html | 7 +- functions_s.html | 2 +- functions_t.html | 1 + functions_vars.html | 11 +- functions_~.html | 1 + globals_func_m.html | 2 +- globals_func_t.html | 2 +- globals_m.html | 2 +- globals_t.html | 2 +- hierarchy.html | 137 ++-- hierarchy.js | 1 + inherit_graph_100.map | 2 +- inherit_graph_100.md5 | 2 +- inherit_graph_100.svg | 13 +- inherit_graph_101.map | 2 +- inherit_graph_101.md5 | 2 +- inherit_graph_101.svg | 10 +- inherit_graph_102.map | 2 +- inherit_graph_102.md5 | 2 +- inherit_graph_102.svg | 10 +- inherit_graph_103.map | 2 +- inherit_graph_103.md5 | 2 +- inherit_graph_103.svg | 10 +- inherit_graph_104.map | 2 +- inherit_graph_104.md5 | 2 +- inherit_graph_104.svg | 10 +- inherit_graph_105.map | 2 +- inherit_graph_105.md5 | 2 +- inherit_graph_105.svg | 4 +- inherit_graph_106.map | 14 +- inherit_graph_106.md5 | 2 +- inherit_graph_106.svg | 122 +--- inherit_graph_107.map | 14 +- inherit_graph_107.md5 | 2 +- inherit_graph_107.svg | 123 +++- inherit_graph_108.map | 2 +- inherit_graph_108.md5 | 2 +- inherit_graph_108.svg | 13 +- inherit_graph_109.map | 2 +- inherit_graph_109.md5 | 2 +- inherit_graph_109.svg | 10 +- inherit_graph_110.map | 2 +- inherit_graph_110.md5 | 2 +- inherit_graph_110.svg | 10 +- inherit_graph_111.map | 2 +- inherit_graph_111.md5 | 2 +- inherit_graph_111.svg | 10 +- inherit_graph_112.map | 2 +- inherit_graph_112.md5 | 2 +- inherit_graph_112.svg | 10 +- inherit_graph_113.map | 2 +- inherit_graph_113.md5 | 2 +- inherit_graph_113.svg | 10 +- inherit_graph_114.map | 2 +- inherit_graph_114.md5 | 2 +- inherit_graph_114.svg | 4 +- inherit_graph_115.map | 3 + inherit_graph_115.md5 | 1 + inherit_graph_115.svg | 21 + inherit_graph_81.map | 2 +- inherit_graph_81.md5 | 2 +- inherit_graph_81.svg | 12 +- inherit_graph_82.map | 2 +- inherit_graph_82.md5 | 2 +- inherit_graph_82.svg | 10 +- inherit_graph_83.map | 2 +- inherit_graph_83.md5 | 2 +- inherit_graph_83.svg | 12 +- inherit_graph_84.map | 2 +- inherit_graph_84.md5 | 2 +- inherit_graph_84.svg | 12 +- inherit_graph_85.map | 2 +- inherit_graph_85.md5 | 2 +- inherit_graph_85.svg | 12 +- inherit_graph_86.map | 2 +- inherit_graph_86.md5 | 2 +- inherit_graph_86.svg | 4 +- inherit_graph_87.map | 2 +- inherit_graph_87.md5 | 2 +- inherit_graph_87.svg | 13 +- inherit_graph_88.map | 2 +- inherit_graph_88.md5 | 2 +- inherit_graph_88.svg | 13 +- inherit_graph_89.map | 2 +- inherit_graph_89.md5 | 2 +- inherit_graph_89.svg | 12 +- inherit_graph_90.map | 2 +- inherit_graph_90.md5 | 2 +- inherit_graph_90.svg | 12 +- inherit_graph_91.map | 2 +- inherit_graph_91.md5 | 2 +- inherit_graph_91.svg | 13 +- inherit_graph_92.map | 2 +- inherit_graph_92.md5 | 2 +- inherit_graph_92.svg | 10 +- inherit_graph_93.map | 2 +- inherit_graph_93.md5 | 2 +- inherit_graph_93.svg | 10 +- inherit_graph_94.map | 2 +- inherit_graph_94.md5 | 2 +- inherit_graph_94.svg | 10 +- inherit_graph_95.map | 6 +- inherit_graph_95.md5 | 2 +- inherit_graph_95.svg | 54 +- inherit_graph_96.map | 6 +- inherit_graph_96.md5 | 2 +- inherit_graph_96.svg | 54 +- inherit_graph_97.map | 2 +- inherit_graph_97.md5 | 2 +- inherit_graph_97.svg | 13 +- inherit_graph_98.map | 2 +- inherit_graph_98.md5 | 2 +- inherit_graph_98.svg | 13 +- inherit_graph_99.map | 2 +- inherit_graph_99.md5 | 2 +- inherit_graph_99.svg | 13 +- inherits.html | 63 +- navtreedata.js | 14 +- navtreeindex10.js | 80 +-- navtreeindex11.js | 70 +- navtreeindex12.js | 94 +-- navtreeindex13.js | 76 +- navtreeindex14.js | 68 +- navtreeindex15.js | 33 + navtreeindex2.js | 18 +- navtreeindex4.js | 8 +- navtreeindex6.js | 4 +- navtreeindex7.js | 38 +- navtreeindex8.js | 62 +- navtreeindex9.js | 62 +- search/all_11.js | 11 +- search/all_12.js | 345 +++++----- search/all_13.js | 4 +- search/all_15.js | 8 +- search/all_18.js | 2 +- search/all_19.js | 343 ++++----- search/all_1a.js | 49 +- search/all_20.js | 121 ++-- search/all_5.js | 2 +- search/all_8.js | 2 +- search/all_a.js | 2 +- search/all_c.js | 2 +- search/all_d.js | 2 +- search/classes_14.js | 15 +- search/classes_b.js | 2 +- search/files_c.js | 5 +- search/functions_10.js | 6 +- search/functions_13.js | 2 +- search/functions_14.js | 2 +- search/functions_1b.js | 121 ++-- search/functions_3.js | 2 +- search/functions_5.js | 2 +- search/functions_7.js | 2 +- search/functions_c.js | 2 +- search/functions_d.js | 203 +++--- search/variables_0.js | 2 +- search/variables_12.js | 7 +- search/variables_8.js | 2 +- search/variables_d.js | 4 +- search/variables_e.js | 2 +- 221 files changed, 4878 insertions(+), 1509 deletions(-) create mode 100644 d1/d35/classothers_1_1_cache_1_1_l_r_u_cache-members.html create mode 100644 d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.map create mode 100644 d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.md5 create mode 100644 d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.svg create mode 100644 d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph_org.svg create mode 100644 d4/d89/lru__cache2_8cpp__incl.map create mode 100644 d4/d89/lru__cache2_8cpp__incl.md5 create mode 100644 d4/d89/lru__cache2_8cpp__incl.svg create mode 100644 d4/d89/lru__cache2_8cpp__incl_org.svg create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.js create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.map create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.md5 create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.svg create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph_org.svg create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.map create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.md5 create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.svg create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph_org.svg create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.map create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.md5 create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.svg create mode 100644 d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph_org.svg create mode 100644 dc/daa/lru__cache2_8cpp.html create mode 100644 dc/daa/lru__cache2_8cpp.js create mode 100644 dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map create mode 100644 dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 create mode 100644 dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg create mode 100644 dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg create mode 100644 dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map create mode 100644 dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 create mode 100644 dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg create mode 100644 dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg create mode 100644 inherit_graph_115.map create mode 100644 inherit_graph_115.md5 create mode 100644 inherit_graph_115.svg diff --git a/annotated.html b/annotated.html index 33467db29..0944faa6a 100644 --- a/annotated.html +++ b/annotated.html @@ -201,6 +201,7 @@ $(function(){initNavTree('annotated.html',''); initResizable(true); });  NCacheCache algorithm  CD_NodeNode for a doubly linked list with data, prev and next pointers  CLFUCacheLFUCache + CLRUCacheLRUCache  Niterative_tree_traversals  CBinaryTreeDefines the functions associated with the binary tree  CNodeDefines the structure of a node of the tree diff --git a/annotated_dup.js b/annotated_dup.js index ab2a78332..e5294b0ee 100644 --- a/annotated_dup.js +++ b/annotated_dup.js @@ -125,7 +125,8 @@ var annotated_dup = [ "others", "d0/d6f/namespaceothers.html", [ [ "Cache", "db/dde/namespaceothers_1_1_cache.html", [ [ "D_Node", "de/d21/classothers_1_1_cache_1_1_d___node.html", "de/d21/classothers_1_1_cache_1_1_d___node" ], - [ "LFUCache", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache" ] + [ "LFUCache", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache" ], + [ "LRUCache", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache" ] ] ], [ "iterative_tree_traversals", null, [ [ "BinaryTree", "d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html", "d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree" ], diff --git a/classes.html b/classes.html index d917b39a1..ed7f62469 100644 --- a/classes.html +++ b/classes.html @@ -141,7 +141,7 @@ $(function(){initNavTree('classes.html',''); initResizable(true); });
Knn (machine_learning::k_nearest_neighbors)
L
-
large_number
LFUCache (others::Cache)
link (data_structures::linked_list)
linkedlist
list (data_structures::linked_list)
list (data_structures::list_array)
list
ListNode
Longest_Substring
LowestCommonAncestor (graph)
LRUCache (others::lru_cache)
+
large_number
LFUCache (others::Cache)
link (data_structures::linked_list)
linkedlist
list (data_structures::linked_list)
list (data_structures::list_array)
list
ListNode
Longest_Substring
LowestCommonAncestor (graph)
LRUCache (others::Cache)
LRUCache (others::lru_cache)
M
Matrix (divide_and_conquer::strassens_multiplication)
MinHeap
MinHeapNode
mst
diff --git a/d1/d35/classothers_1_1_cache_1_1_l_r_u_cache-members.html b/d1/d35/classothers_1_1_cache_1_1_l_r_u_cache-members.html new file mode 100644 index 000000000..737c0c237 --- /dev/null +++ b/d1/d35/classothers_1_1_cache_1_1_l_r_u_cache-members.html @@ -0,0 +1,136 @@ + + + + + + + +Algorithms_in_C++: Member List + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
others::Cache::LRUCache< K, V > Member List
+
+ +
+ + + + diff --git a/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.map b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.map new file mode 100644 index 000000000..4a8ad8eb9 --- /dev/null +++ b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.map @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.md5 b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.md5 new file mode 100644 index 000000000..572d4f653 --- /dev/null +++ b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.md5 @@ -0,0 +1 @@ +000048512d2af21496e0d3a3054ece76 \ No newline at end of file diff --git a/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.svg b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.svg new file mode 100644 index 000000000..0a6584801 --- /dev/null +++ b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph.svg @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +others::Cache::LRUCache< K, V > + + +Node1 + + +others::Cache::LRUCache +< K, V > + + + + + +Node2 + + +others::Cache::D_Node +< K, V > + + + + + +Node2->Node1 + + + + + + head +tail + + + +Node5 + + +std::unordered_map +< K, others::Cache:: +D_Node< K, V > * > + + + + + +Node2->Node5 + + + + + + elements + + + +Node3 + + +K + + + + + +Node3->Node2 + + + + + + data + + + +Node3->Node5 + + + + + + keys + + + +Node4 + + +std::uint32_t + + + + + +Node4->Node1 + + + + + + _capacity + + + +Node5->Node1 + + + + + + node_map + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph_org.svg b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph_org.svg new file mode 100644 index 000000000..b244c724d --- /dev/null +++ b/d1/db8/classothers_1_1_cache_1_1_l_r_u_cache__coll__graph_org.svg @@ -0,0 +1,122 @@ + + + + + + +others::Cache::LRUCache< K, V > + + +Node1 + + +others::Cache::LRUCache +< K, V > + + + + + +Node2 + + +others::Cache::D_Node +< K, V > + + + + + +Node2->Node1 + + + + + + head +tail + + + +Node5 + + +std::unordered_map +< K, others::Cache:: +D_Node< K, V > * > + + + + + +Node2->Node5 + + + + + + elements + + + +Node3 + + +K + + + + + +Node3->Node2 + + + + + + data + + + +Node3->Node5 + + + + + + keys + + + +Node4 + + +std::uint32_t + + + + + +Node4->Node1 + + + + + + _capacity + + + +Node5->Node1 + + + + + + node_map + + + diff --git a/d4/d89/lru__cache2_8cpp__incl.map b/d4/d89/lru__cache2_8cpp__incl.map new file mode 100644 index 000000000..806cd319a --- /dev/null +++ b/d4/d89/lru__cache2_8cpp__incl.map @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/d4/d89/lru__cache2_8cpp__incl.md5 b/d4/d89/lru__cache2_8cpp__incl.md5 new file mode 100644 index 000000000..2ffca79f0 --- /dev/null +++ b/d4/d89/lru__cache2_8cpp__incl.md5 @@ -0,0 +1 @@ +e1492a5cdea2a46801d6a759537c77be \ No newline at end of file diff --git a/d4/d89/lru__cache2_8cpp__incl.svg b/d4/d89/lru__cache2_8cpp__incl.svg new file mode 100644 index 000000000..2d0b79c8d --- /dev/null +++ b/d4/d89/lru__cache2_8cpp__incl.svg @@ -0,0 +1,119 @@ + + + + + + + + + + + + +others/lru_cache2.cpp + + +Node1 + + +others/lru_cache2.cpp + + + + + +Node2 + + +cassert + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +cstdint + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +iostream + + + + + +Node1->Node4 + + + + + + + + +Node5 + + +unordered_map + + + + + +Node1->Node5 + + + + + + + + + + + + + diff --git a/d4/d89/lru__cache2_8cpp__incl_org.svg b/d4/d89/lru__cache2_8cpp__incl_org.svg new file mode 100644 index 000000000..c69ca6a2c --- /dev/null +++ b/d4/d89/lru__cache2_8cpp__incl_org.svg @@ -0,0 +1,93 @@ + + + + + + +others/lru_cache2.cpp + + +Node1 + + +others/lru_cache2.cpp + + + + + +Node2 + + +cassert + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +cstdint + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +iostream + + + + + +Node1->Node4 + + + + + + + + +Node5 + + +unordered_map + + + + + +Node1->Node5 + + + + + + + + diff --git a/d5/ddb/classothers_1_1_cache_1_1_d___node-members.html b/d5/ddb/classothers_1_1_cache_1_1_d___node-members.html index 99f4bf590..e9be37226 100644 --- a/d5/ddb/classothers_1_1_cache_1_1_d___node-members.html +++ b/d5/ddb/classothers_1_1_cache_1_1_d___node-members.html @@ -111,9 +111,10 @@ $(function(){initNavTree('de/d21/classothers_1_1_cache_1_1_d___node.html','../..

This is the complete list of members for others::Cache::D_Node< T >, including all inherited members.

- - - + + + +
D_Node(T data) (defined in others::Cache::D_Node< T >)others::Cache::D_Node< T >inlineexplicit
dataothers::Cache::D_Node< T >
nextothers::Cache::D_Node< T >
prevothers::Cache::D_Node< T >
D_Node(T data) (defined in others::Cache::D_Node< T >)others::Cache::D_Node< T >inlineexplicit
dataothers::Cache::D_Node< T >
nextothers::Cache::D_Node< T >
prevothers::Cache::D_Node< T >
diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html new file mode 100644 index 000000000..224cdb5f2 --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html @@ -0,0 +1,651 @@ + + + + + + + +Algorithms_in_C++: others::Cache::LRUCache< K, V > Class Template Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
others::Cache::LRUCache< K, V > Class Template Reference
+
+
+ +

LRUCache. + More...

+
+Collaboration diagram for others::Cache::LRUCache< K, V >:
+
+
+
[legend]
+ + + + + + + + + + + + + + + + + + + + + + + +

+Public Member Functions

 LRUCache (int _capacity)
 Constructor, Initialize the head and tail pointers to nullptr and initialize the _capacity of the cache.
 
void put (K key, V value)
 upsert a key-value pair
 
get (K key)
 get the value of the key-value pair if exists
 
int size () const
 Returns the number of items present in the cache.
 
int capacity () const
 Returns the total capacity of the cache.
 
bool empty () const
 returns whether the cache is empty or not
 
 ~LRUCache ()
 destructs the cache, iterates on the map and deletes every node present in the cache.
 
+ + + + + + + + + + +

+Private Member Functions

void push_front (CacheNode< K, V > *node_ptr)
 push the node to the front of the linked list.
 
void make_recent (CacheNode< K, V > *node_ptr)
 move the existing node in the list to the beginning of the list.
 
void pop_back ()
 pop the last node in the linked list.
 
+ + + + + + + + + + + + + +

+Private Attributes

+CacheNode< K, V > * head
 head of the doubly linked list
 
+CacheNode< K, V > * tail
 tail of the doubly linked list
 
+std::uint32_t _capacity
 maximum capacity of the cache
 
+std::unordered_map< K, CacheNode< K, V > * > node_map
 maps the key to the node address
 
+

Detailed Description

+
template<typename K, typename V>
+class others::Cache::LRUCache< K, V >

LRUCache.

+
Template Parameters
+ + + +
Ktype of key in the LRU
Vtype of value in the LRU
+
+
+

Constructor & Destructor Documentation

+ +

◆ LRUCache()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
others::Cache::LRUCache< K, V >::LRUCache (int _capacity)
+
+inlineexplicit
+
+ +

Constructor, Initialize the head and tail pointers to nullptr and initialize the _capacity of the cache.

+
Parameters
+ + +
_capacityTotal capacity of the cache
+
+
+
76 : head(nullptr), tail(nullptr), _capacity(_capacity) {}
+
CacheNode< K, V > * head
head of the doubly linked list
Definition lru_cache2.cpp:62
+
CacheNode< K, V > * tail
tail of the doubly linked list
Definition lru_cache2.cpp:63
+
std::uint32_t _capacity
maximum capacity of the cache
Definition lru_cache2.cpp:64
+
+
+
+ +

◆ ~LRUCache()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
others::Cache::LRUCache< K, V >::~LRUCache ()
+
+inline
+
+ +

destructs the cache, iterates on the map and deletes every node present in the cache.

+
205 {
+
206 auto it = node_map.begin();
+
207 while (it != node_map.end()) {
+
208 delete it->second;
+
209 ++it;
+
210 }
+
211 }
+
std::unordered_map< K, CacheNode< K, V > * > node_map
maps the key to the node address
Definition lru_cache2.cpp:67
+
+
+
+

Member Function Documentation

+ +

◆ capacity()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
int others::Cache::LRUCache< K, V >::capacity () const
+
+inline
+
+ +

Returns the total capacity of the cache.

+
Returns
Total capacity of the cache
+
193{ return _capacity; }
+
+
+
+ +

◆ empty()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
bool others::Cache::LRUCache< K, V >::empty () const
+
+inline
+
+ +

returns whether the cache is empty or not

+
Returns
true if the cache is empty, false otherwise.
+
199{ return node_map.empty(); }
+
+
+
+ +

◆ get()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
V others::Cache::LRUCache< K, V >::get (K key)
+
+inline
+
+ +

get the value of the key-value pair if exists

+
Parameters
+ + +
keykey of the key-value pair
+
+
+
Returns
the value mapped to the given key
+
Exceptions
+ + +
exceptionis thrown if the key is not present in the cache
+
+
+
172 {
+
173 if (!node_map.count(key)) {
+
174 throw std::runtime_error("key is not present in the cache");
+
175 }
+
176
+
177 // move node to the beginning of the list
+
178 V value = node_map[key]->data.second;
+
179 make_recent(node_map[key]);
+
180 return value;
+
181 }
+
void make_recent(CacheNode< K, V > *node_ptr)
move the existing node in the list to the beginning of the list.
Definition lru_cache2.cpp:99
+ +
+Here is the call graph for this function:
+
+
+
+ +
+
+ +

◆ make_recent()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
void others::Cache::LRUCache< K, V >::make_recent (CacheNode< K, V > * node_ptr)
+
+inlineprivate
+
+ +

move the existing node in the list to the beginning of the list.

+
Parameters
+ + +
node_ptrnode to be moved to the beginning.
+
+
+
99 {
+
100 if (head == node_ptr) {
+
101 return;
+
102 }
+
103
+
104 CacheNode<K, V> *prev = node_ptr->prev;
+
105 CacheNode<K, V> *next = node_ptr->next;
+
106
+
107 prev->next = next;
+
108 if (next) {
+
109 next->prev = prev;
+
110 } else {
+
111 tail = prev;
+
112 }
+
113
+
114 node_ptr->prev = nullptr;
+
115 node_ptr->next = nullptr;
+
116 push_front(node_ptr);
+
117 }
+
void push_front(CacheNode< K, V > *node_ptr)
push the node to the front of the linked list.
Definition lru_cache2.cpp:83
+
T next(T... args)
+
T prev(T... args)
+
+Here is the call graph for this function:
+
+
+
+ +
+
+ +

◆ pop_back()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
void others::Cache::LRUCache< K, V >::pop_back ()
+
+inlineprivate
+
+ +

pop the last node in the linked list.

+
122 {
+
123 if (!head) {
+
124 return;
+
125 }
+
126 if (head == tail) {
+
127 delete head;
+
128 head = nullptr;
+
129 tail = nullptr;
+
130 return;
+
131 }
+
132
+
133 CacheNode<K, V> *temp = tail;
+
134 tail = tail->prev;
+
135 tail->next = nullptr;
+
136 delete temp;
+
137 }
+
+
+
+ +

◆ push_front()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
void others::Cache::LRUCache< K, V >::push_front (CacheNode< K, V > * node_ptr)
+
+inlineprivate
+
+ +

push the node to the front of the linked list.

+
Parameters
+ + +
node_ptrthe node to be pushed
+
+
+
83 {
+
84 if (!head) {
+
85 head = node_ptr;
+
86 tail = node_ptr;
+
87 return;
+
88 }
+
89
+
90 node_ptr->next = head;
+
91 head->prev = node_ptr;
+
92 head = node_ptr;
+
93 }
+
+
+
+ +

◆ put()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + + + + + +
void others::Cache::LRUCache< K, V >::put (K key,
V value )
+
+inline
+
+ +

upsert a key-value pair

+
Parameters
+ + + +
keykey of the key-value pair
valuevalue of the key-value pair
+
+
+
145 {
+
146 // update the value if key already exists
+
147 if (node_map.count(key)) {
+
148 node_map[key]->data.second = value;
+
149 make_recent(node_map[key]);
+
150 return;
+
151 }
+
152
+
153 // if the cache is full
+
154 // remove the least recently used item
+
155 if (node_map.size() == _capacity) {
+
156 node_map.erase(tail->data.first);
+
157 pop_back();
+
158 }
+
159
+
160 CacheNode<K, V> *newNode = new CacheNode<K, V>({key, value});
+
161
+
162 node_map[key] = newNode;
+
163 push_front(newNode);
+
164 }
+
void pop_back()
pop the last node in the linked list.
Definition lru_cache2.cpp:122
+
+Here is the call graph for this function:
+
+
+
+ +
+
+ +

◆ size()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
int others::Cache::LRUCache< K, V >::size () const
+
+inline
+
+ +

Returns the number of items present in the cache.

+
Returns
number of items in the cache
+
187{ return node_map.size(); }
+
+
+
+
The documentation for this class was generated from the following file: +
+
+ + + + diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.js b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.js new file mode 100644 index 000000000..ee7f7d5a1 --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.js @@ -0,0 +1,17 @@ +var classothers_1_1_cache_1_1_l_r_u_cache = +[ + [ "LRUCache", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a8980cbbc9cf0a98a9592b40c4d6ec28f", null ], + [ "~LRUCache", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a6d855ff72ad6fe548eb564b7f87abe06", null ], + [ "capacity", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#af8edfe5a7def5d5b846463041c33136a", null ], + [ "empty", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#ab8b6a6aa95db678596bc2a49e864683e", null ], + [ "get", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#ac1be0357ecc7c34144f3d9a63c6cb3ea", null ], + [ "make_recent", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#ad022d494b40f82417340b113445e79a4", null ], + [ "pop_back", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#ab211a4be58491bf11834cae88a0c44f7", null ], + [ "push_front", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a2e53b5ad1368d87da501f61473eb9ea2", null ], + [ "put", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a5ee34fcee480f21bb6f68a34f0f69b45", null ], + [ "size", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a1b709333874b4633ee02a3661cd042e1", null ], + [ "_capacity", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#af34bb8b8eaa34cc499b4fed30b9d05fc", null ], + [ "head", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a042bb403f4452ad8c669fbf87ef82821", null ], + [ "node_map", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a8dab0f69410484f772946befd24cc3c5", null ], + [ "tail", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100", null ] +]; \ No newline at end of file diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.map b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.map new file mode 100644 index 000000000..bcfd66e0a --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.map @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.md5 b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.md5 new file mode 100644 index 000000000..806b8d3a9 --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.md5 @@ -0,0 +1 @@ +e39d6679ed29b64bafd84cc0e32ad7af \ No newline at end of file diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.svg b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.svg new file mode 100644 index 000000000..259f4d415 --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph.svg @@ -0,0 +1,113 @@ + + + + + + + + + + + + +others::Cache::LRUCache::put + + +Node1 + + +others::Cache::LRUCache::put + + + + + +Node2 + + +others::Cache::LRUCache +::make_recent + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LRUCache +::push_front + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +others::Cache::LRUCache +::pop_back + + + + + +Node1->Node4 + + + + + + + + +Node2->Node3 + + + + + + + + + + + + + diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph_org.svg b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph_org.svg new file mode 100644 index 000000000..f847ad875 --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_a5ee34fcee480f21bb6f68a34f0f69b45_cgraph_org.svg @@ -0,0 +1,87 @@ + + + + + + +others::Cache::LRUCache::put + + +Node1 + + +others::Cache::LRUCache::put + + + + + +Node2 + + +others::Cache::LRUCache +::make_recent + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LRUCache +::push_front + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +others::Cache::LRUCache +::pop_back + + + + + +Node1->Node4 + + + + + + + + +Node2->Node3 + + + + + + + + diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.map b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.map new file mode 100644 index 000000000..d37fae53a --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.map @@ -0,0 +1,7 @@ + + + + + + + diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.md5 b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.md5 new file mode 100644 index 000000000..a2f67752e --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.md5 @@ -0,0 +1 @@ +1fb368e2a63e8485f9982b788e14a41a \ No newline at end of file diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.svg b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.svg new file mode 100644 index 000000000..3fcd61739 --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + +others::Cache::LRUCache::get + + +Node1 + + +others::Cache::LRUCache::get + + + + + +Node2 + + +others::Cache::LRUCache +::make_recent + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LRUCache +::push_front + + + + + +Node2->Node3 + + + + + + + + + + + + + diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph_org.svg b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph_org.svg new file mode 100644 index 000000000..45be5a3ed --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ac1be0357ecc7c34144f3d9a63c6cb3ea_cgraph_org.svg @@ -0,0 +1,59 @@ + + + + + + +others::Cache::LRUCache::get + + +Node1 + + +others::Cache::LRUCache::get + + + + + +Node2 + + +others::Cache::LRUCache +::make_recent + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LRUCache +::push_front + + + + + +Node2->Node3 + + + + + + + + diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.map b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.map new file mode 100644 index 000000000..59eb6160a --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.md5 b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.md5 new file mode 100644 index 000000000..47e7166c7 --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.md5 @@ -0,0 +1 @@ +c62f379001ef2b4ca1c6f7e1af924130 \ No newline at end of file diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.svg b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.svg new file mode 100644 index 000000000..a1fba2ffe --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + +others::Cache::LRUCache::make_recent + + +Node1 + + +others::Cache::LRUCache +::make_recent + + + + + +Node2 + + +others::Cache::LRUCache +::push_front + + + + + +Node1->Node2 + + + + + + + + + + + + + diff --git a/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph_org.svg b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph_org.svg new file mode 100644 index 000000000..f4df1b958 --- /dev/null +++ b/d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache_ad022d494b40f82417340b113445e79a4_cgraph_org.svg @@ -0,0 +1,41 @@ + + + + + + +others::Cache::LRUCache::make_recent + + +Node1 + + +others::Cache::LRUCache +::make_recent + + + + + +Node2 + + +others::Cache::LRUCache +::push_front + + + + + +Node1->Node2 + + + + + + + + diff --git a/db/dde/namespaceothers_1_1_cache.html b/db/dde/namespaceothers_1_1_cache.html index 4c1259356..cb4058a69 100644 --- a/db/dde/namespaceothers_1_1_cache.html +++ b/db/dde/namespaceothers_1_1_cache.html @@ -122,6 +122,9 @@ Classes class  LFUCache  LFUCache. More...
  +class  LRUCacheLRUCache. More...
+  diff --git a/db/dde/namespaceothers_1_1_cache.js b/db/dde/namespaceothers_1_1_cache.js index 9817e71e3..b7d82db9c 100644 --- a/db/dde/namespaceothers_1_1_cache.js +++ b/db/dde/namespaceothers_1_1_cache.js @@ -1,5 +1,6 @@ var namespaceothers_1_1_cache = [ [ "D_Node", "de/d21/classothers_1_1_cache_1_1_d___node.html", "de/d21/classothers_1_1_cache_1_1_d___node" ], - [ "LFUCache", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache" ] + [ "LFUCache", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache" ], + [ "LRUCache", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache" ] ]; \ No newline at end of file diff --git a/dc/daa/lru__cache2_8cpp.html b/dc/daa/lru__cache2_8cpp.html new file mode 100644 index 000000000..b9cbdbc14 --- /dev/null +++ b/dc/daa/lru__cache2_8cpp.html @@ -0,0 +1,288 @@ + + + + + + + +Algorithms_in_C++: others/lru_cache2.cpp File Reference + + + + + + + + + + + + + + + + + +
+
+

Typedefs

+ + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+ + + + + + + + + + +
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
lru_cache2.cpp File Reference
+
+
+ +

Implementation for [LRU Cache] (https://en.wikipedia.org/wiki/Cache_replacement_policies#:~:text=Least%20Recently%20Used%20(LRU)) +More...

+
#include <cassert>
+#include <cstdint>
+#include <iostream>
+#include <unordered_map>
+
+Include dependency graph for lru_cache2.cpp:
+
+
+
+
+ + + + + + + +

+Classes

class  others::Cache::D_Node< T >
 Node for a doubly linked list with data, prev and next pointers. More...
 
class  others::Cache::LRUCache< K, V >
 LRUCache. More...
 
+ + + + + + + +

+Namespaces

namespace  others
 for vector
 
namespace  others::Cache
 Cache algorithm.
 
+ + + + + + + +

+Functions

static void test ()
 self test implementations
 
int main ()
 main function
 
+

Detailed Description

+

Implementation for [LRU Cache] (https://en.wikipedia.org/wiki/Cache_replacement_policies#:~:text=Least%20Recently%20Used%20(LRU))

+

LRU discards the least recently used value. Data structures used - doubly linked list and unordered_map

+

unordered_map maps the key to the address of the node of the linked list. If the element is accessed, the element is moved to the beginning of the linked list.

+

When the cache is full, the last element in the linked list is popped.

+
Author
Karan Sharma
+

Function Documentation

+ +

◆ main()

+ +
+
+ + + + + + + +
int main (void )
+
+ +

main function

+
Returns
0 on exit
+
274 {
+
275 test(); // run the self test implementation
+
276 return 0;
+
277}
+
static void test()
self test implementations
Definition lru_cache2.cpp:220
+
+Here is the call graph for this function:
+
+
+
+ +
+
+ +

◆ test()

+ +
+
+ + + + + +
+ + + + + + + +
static void test ()
+
+static
+
+ +

self test implementations

+
Returns
void
+
220 {
+ +
222
+
223 // test the initial state of the cache
+
224 assert(cache.size() == 0);
+
225 assert(cache.capacity() == 5);
+
226 assert(cache.empty());
+
227
+
228 // test insertion in the cache
+
229 cache.put(1, 10);
+
230 cache.put(-2, 20);
+
231
+
232 // test the state of cache after inserting some items
+
233 assert(cache.size() == 2);
+
234 assert(cache.capacity() == 5);
+
235 assert(!cache.empty());
+
236
+
237 // test getting items from the cache
+
238 assert(cache.get(1) == 10);
+
239 assert(cache.get(-2) == 20);
+
240
+
241 cache.put(-3, -30);
+
242 cache.put(4, 40);
+
243 cache.put(5, -50);
+
244 cache.put(6, 60);
+
245
+
246 // test the state after inserting more items than the capacity
+
247 assert(cache.size() == 5);
+
248 assert(cache.capacity() == 5);
+
249 assert(!cache.empty());
+
250
+
251 // fetching 1 throws runtime_error
+
252 // as 1 was evicted being the least recently used
+
253 // when 6 was added
+
254 try {
+
255 cache.get(1);
+
256 } catch (const std::runtime_error &e) {
+
257 assert(std::string(e.what()) == "key is not present in the cache");
+
258 }
+
259
+
260 // test retrieval of all items in the cache
+
261 assert(cache.get(-2) == 20);
+
262 assert(cache.get(-3) == -30);
+
263 assert(cache.get(4) == 40);
+
264 assert(cache.get(5) == -50);
+
265 assert(cache.get(6) == 60);
+
266
+
267 std::cout << "test - passed\n";
+
268}
+ + +
LRUCache.
Definition lru_cache2.cpp:61
+ +
T what(T... args)
+
+Here is the call graph for this function:
+
+
+
+ +
+
+
+
+ + + + diff --git a/dc/daa/lru__cache2_8cpp.js b/dc/daa/lru__cache2_8cpp.js new file mode 100644 index 000000000..d4f7a68e2 --- /dev/null +++ b/dc/daa/lru__cache2_8cpp.js @@ -0,0 +1,7 @@ +var lru__cache2_8cpp = +[ + [ "others::Cache::D_Node< T >", "de/d21/classothers_1_1_cache_1_1_d___node.html", "de/d21/classothers_1_1_cache_1_1_d___node" ], + [ "others::Cache::LRUCache< K, V >", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html", "d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache" ], + [ "main", "dc/daa/lru__cache2_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], + [ "test", "dc/daa/lru__cache2_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ] +]; \ No newline at end of file diff --git a/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map new file mode 100644 index 000000000..ef772fbcd --- /dev/null +++ b/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 new file mode 100644 index 000000000..39bfb0596 --- /dev/null +++ b/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -0,0 +1 @@ +97c1ae9df20c10d14b9ce242561c8cd9 \ No newline at end of file diff --git a/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg new file mode 100644 index 000000000..3ef1f5837 --- /dev/null +++ b/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +test + + +Node1 + + +test + + + + + +Node2 + + +others::Cache::LRUCache +::capacity + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LRUCache +::empty + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +others::Cache::LRUCache::get + + + + + +Node1->Node4 + + + + + + + + +Node7 + + +others::Cache::LRUCache::put + + + + + +Node1->Node7 + + + + + + + + +Node9 + + +others::Cache::LRUCache +::size + + + + + +Node1->Node9 + + + + + + + + +Node10 + + +std::runtime_error +::what + + + + + +Node1->Node10 + + + + + + + + +Node5 + + +others::Cache::LRUCache +::make_recent + + + + + +Node4->Node5 + + + + + + + + +Node6 + + +others::Cache::LRUCache +::push_front + + + + + +Node5->Node6 + + + + + + + + +Node7->Node5 + + + + + + + + +Node7->Node6 + + + + + + + + +Node8 + + +others::Cache::LRUCache +::pop_back + + + + + +Node7->Node8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg b/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg new file mode 100644 index 000000000..2dbd8436e --- /dev/null +++ b/dc/daa/lru__cache2_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg @@ -0,0 +1,208 @@ + + + + + + +test + + +Node1 + + +test + + + + + +Node2 + + +others::Cache::LRUCache +::capacity + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LRUCache +::empty + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +others::Cache::LRUCache::get + + + + + +Node1->Node4 + + + + + + + + +Node7 + + +others::Cache::LRUCache::put + + + + + +Node1->Node7 + + + + + + + + +Node9 + + +others::Cache::LRUCache +::size + + + + + +Node1->Node9 + + + + + + + + +Node10 + + +std::runtime_error +::what + + + + + +Node1->Node10 + + + + + + + + +Node5 + + +others::Cache::LRUCache +::make_recent + + + + + +Node4->Node5 + + + + + + + + +Node6 + + +others::Cache::LRUCache +::push_front + + + + + +Node5->Node6 + + + + + + + + +Node7->Node5 + + + + + + + + +Node7->Node6 + + + + + + + + +Node8 + + +others::Cache::LRUCache +::pop_back + + + + + +Node7->Node8 + + + + + + + + diff --git a/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map new file mode 100644 index 000000000..f5add5a10 --- /dev/null +++ b/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 new file mode 100644 index 000000000..20f438740 --- /dev/null +++ b/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -0,0 +1 @@ +70630744275453827fd653376a53c592 \ No newline at end of file diff --git a/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg new file mode 100644 index 000000000..f809cad02 --- /dev/null +++ b/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -0,0 +1,309 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +main + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LRUCache +::capacity + + + + + +Node2->Node3 + + + + + + + + +Node4 + + +others::Cache::LRUCache +::empty + + + + + +Node2->Node4 + + + + + + + + +Node5 + + +others::Cache::LRUCache::get + + + + + +Node2->Node5 + + + + + + + + +Node8 + + +others::Cache::LRUCache::put + + + + + +Node2->Node8 + + + + + + + + +Node10 + + +others::Cache::LRUCache +::size + + + + + +Node2->Node10 + + + + + + + + +Node11 + + +std::runtime_error +::what + + + + + +Node2->Node11 + + + + + + + + +Node6 + + +others::Cache::LRUCache +::make_recent + + + + + +Node5->Node6 + + + + + + + + +Node7 + + +others::Cache::LRUCache +::push_front + + + + + +Node6->Node7 + + + + + + + + +Node8->Node6 + + + + + + + + +Node8->Node7 + + + + + + + + +Node9 + + +others::Cache::LRUCache +::pop_back + + + + + +Node8->Node9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg b/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg new file mode 100644 index 000000000..aab4efffc --- /dev/null +++ b/dc/daa/lru__cache2_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg @@ -0,0 +1,226 @@ + + + + + + +main + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LRUCache +::capacity + + + + + +Node2->Node3 + + + + + + + + +Node4 + + +others::Cache::LRUCache +::empty + + + + + +Node2->Node4 + + + + + + + + +Node5 + + +others::Cache::LRUCache::get + + + + + +Node2->Node5 + + + + + + + + +Node8 + + +others::Cache::LRUCache::put + + + + + +Node2->Node8 + + + + + + + + +Node10 + + +others::Cache::LRUCache +::size + + + + + +Node2->Node10 + + + + + + + + +Node11 + + +std::runtime_error +::what + + + + + +Node2->Node11 + + + + + + + + +Node6 + + +others::Cache::LRUCache +::make_recent + + + + + +Node5->Node6 + + + + + + + + +Node7 + + +others::Cache::LRUCache +::push_front + + + + + +Node6->Node7 + + + + + + + + +Node8->Node6 + + + + + + + + +Node8->Node7 + + + + + + + + +Node9 + + +others::Cache::LRUCache +::pop_back + + + + + +Node8->Node9 + + + + + + + + diff --git a/de/d21/classothers_1_1_cache_1_1_d___node.html b/de/d21/classothers_1_1_cache_1_1_d___node.html index 12eca7324..e109de17f 100644 --- a/de/d21/classothers_1_1_cache_1_1_d___node.html +++ b/de/d21/classothers_1_1_cache_1_1_d___node.html @@ -124,6 +124,8 @@ Collaboration diagram for others::Cache::D_Node< T >: Public Member Functions  D_Node (T data)   + D_Node (T data) +  @@ -131,14 +133,14 @@ Public Attributes T  - - - - + + - - + +

Public Attributes

data
 data of the node
 
+
D_Node< T > * prev
 previous node in the doubly linked list
 
+
 previous node in the doubly linked list
 
D_Node< T > * next
 next node in the doubly linked list
 
 next node in the doubly linked list
 

Detailed Description

template<typename T>
@@ -151,7 +153,7 @@ class others::Cache::D_Node< T >

Constructor & Destructor Documentation -

◆ D_Node()

+

◆ D_Node() [1/2]

@@ -174,15 +176,44 @@ template<typename T >
-
51: data(data), prev(nullptr), next(nullptr) {}
-
D_Node< T > * prev
previous node in the doubly linked list
Definition lfu_cache.cpp:48
+
51: data(data), prev(nullptr), next(nullptr) {}
+
D_Node< T > * next
next node in the doubly linked list
Definition lfu_cache.cpp:49
+
D_Node< T > * prev
previous node in the doubly linked list
Definition lfu_cache.cpp:48
T data
data of the node
Definition lfu_cache.cpp:47
-
D_Node< T > * next
next node in the doubly linked list
Definition lfu_cache.cpp:49
-
The documentation for this class was generated from the following file:
diff --git a/de/d21/classothers_1_1_cache_1_1_d___node.js b/de/d21/classothers_1_1_cache_1_1_d___node.js index c24cc15b6..460f3d314 100644 --- a/de/d21/classothers_1_1_cache_1_1_d___node.js +++ b/de/d21/classothers_1_1_cache_1_1_d___node.js @@ -1,6 +1,6 @@ var classothers_1_1_cache_1_1_d___node = [ [ "data", "de/d21/classothers_1_1_cache_1_1_d___node.html#a8902e7ff872fa3c80fe6ce5f5cf5cc75", null ], - [ "next", "de/d21/classothers_1_1_cache_1_1_d___node.html#a99420ff7864ecea51429fe61f9c6cb14", null ], - [ "prev", "de/d21/classothers_1_1_cache_1_1_d___node.html#a1c5295011209f1241fa0aac827129414", null ] + [ "next", "de/d21/classothers_1_1_cache_1_1_d___node.html#a0043eb287c54b3b2fb91ce354878a7bd", null ], + [ "prev", "de/d21/classothers_1_1_cache_1_1_d___node.html#a19e954cbb710ea8318bcb6aaef78e2d5", null ] ]; \ No newline at end of file diff --git a/dir_9510827d0b234b3cc54b29892f217477.html b/dir_9510827d0b234b3cc54b29892f217477.html index 30fca4c8f..eef24b88c 100644 --- a/dir_9510827d0b234b3cc54b29892f217477.html +++ b/dir_9510827d0b234b3cc54b29892f217477.html @@ -146,6 +146,9 @@ Files  lru_cache.cpp  An implementation of LRU Cache. Lru is a part of cache algorithms (also frequently called cache replacement algorithms or cache replacement policies).
  + lru_cache2.cpp + Implementation for [LRU Cache] (https://en.wikipedia.org/wiki/Cache_replacement_policies#:~:text=Least%20Recently%20Used%20(LRU))
 matrix_exponentiation.cpp  Matrix Exponentiation.
  diff --git a/dir_9510827d0b234b3cc54b29892f217477.js b/dir_9510827d0b234b3cc54b29892f217477.js index 9465179fe..f648abcff 100644 --- a/dir_9510827d0b234b3cc54b29892f217477.js +++ b/dir_9510827d0b234b3cc54b29892f217477.js @@ -12,6 +12,7 @@ var dir_9510827d0b234b3cc54b29892f217477 = [ "lfu_cache.cpp", "d9/d65/lfu__cache_8cpp.html", "d9/d65/lfu__cache_8cpp" ], [ "longest_substring_without_repeating_characters.cpp", "d4/db8/longest__substring__without__repeating__characters_8cpp.html", "d4/db8/longest__substring__without__repeating__characters_8cpp" ], [ "lru_cache.cpp", "d3/db3/lru__cache_8cpp.html", "d3/db3/lru__cache_8cpp" ], + [ "lru_cache2.cpp", "dc/daa/lru__cache2_8cpp.html", "dc/daa/lru__cache2_8cpp" ], [ "matrix_exponentiation.cpp", "d7/d35/matrix__exponentiation_8cpp.html", "d7/d35/matrix__exponentiation_8cpp" ], [ "palindrome_of_number.cpp", "da/d9a/palindrome__of__number_8cpp.html", "da/d9a/palindrome__of__number_8cpp" ], [ "paranthesis_matching.cpp", "dc/dc5/paranthesis__matching_8cpp.html", "dc/dc5/paranthesis__matching_8cpp" ], diff --git a/doxygen_crawl.html b/doxygen_crawl.html index d2640dfcb..f616c8aa2 100644 --- a/doxygen_crawl.html +++ b/doxygen_crawl.html @@ -237,6 +237,7 @@ + @@ -611,6 +612,8 @@ + + @@ -2437,6 +2440,21 @@ + + + + + + + + + + + + + + + @@ -3428,6 +3446,9 @@ + + + @@ -3752,9 +3773,9 @@ - + + - diff --git a/files.html b/files.html index 6c7b26572..3ba9de1b4 100644 --- a/files.html +++ b/files.html @@ -347,19 +347,20 @@ N)\) time, with precision fixed using lfu_cache.cppImplementation for [LFU Cache] (https://en.wikipedia.org/wiki/Least_frequently_used)  longest_substring_without_repeating_characters.cppSolution for Longest Substring Without Repeating Characters problem  lru_cache.cppAn implementation of LRU Cache. Lru is a part of cache algorithms (also frequently called cache replacement algorithms or cache replacement policies) - matrix_exponentiation.cppMatrix Exponentiation - palindrome_of_number.cppCheck if a number is palindrome or not - paranthesis_matching.cppPerform paranthesis matching - pascal_triangle.cppPascal's triangle implementation - postfix_evaluation.cppEvaluation of Postfix Expression - primality_test.cppPrimality test implementation - recursive_tree_traversal.cppRecursive version of Inorder, Preorder, and Postorder [Traversal of the Tree] (https://en.wikipedia.org/wiki/Tree_traversal) - smallest_circle.cppGet centre and radius of the smallest circle that circumscribes given set of points - sparse_matrix.cpp - spiral_print.cppPrint the elements of a matrix traversing it spirally - stairs_pattern.cppThis program is use to print the following pattern - tower_of_hanoi.cppSolve the Tower of Hanoi problem - vector_important_functions.cppA C++ program to demonstrate working of std::sort(), std::reverse() + lru_cache2.cppImplementation for [LRU Cache] (https://en.wikipedia.org/wiki/Cache_replacement_policies#:~:text=Least%20Recently%20Used%20(LRU)) + matrix_exponentiation.cppMatrix Exponentiation + palindrome_of_number.cppCheck if a number is palindrome or not + paranthesis_matching.cppPerform paranthesis matching + pascal_triangle.cppPascal's triangle implementation + postfix_evaluation.cppEvaluation of Postfix Expression + primality_test.cppPrimality test implementation + recursive_tree_traversal.cppRecursive version of Inorder, Preorder, and Postorder [Traversal of the Tree] (https://en.wikipedia.org/wiki/Tree_traversal) + smallest_circle.cppGet centre and radius of the smallest circle that circumscribes given set of points + sparse_matrix.cpp + spiral_print.cppPrint the elements of a matrix traversing it spirally + stairs_pattern.cppThis program is use to print the following pattern + tower_of_hanoi.cppSolve the Tower of Hanoi problem + vector_important_functions.cppA C++ program to demonstrate working of std::sort(), std::reverse()   physics  ground_to_ground_projectile_motion.cppGround to ground projectile motion equation implementations   probability diff --git a/functions.html b/functions.html index c98376b6a..53de1791a 100644 --- a/functions.html +++ b/functions.html @@ -109,7 +109,7 @@ $(function(){initNavTree('functions.html',''); initResizable(true); });

- _ -