diff --git a/annotated.html b/annotated.html index bf6e86aca..4cab3351d 100644 --- a/annotated.html +++ b/annotated.html @@ -197,16 +197,19 @@ $(function(){initNavTree('annotated.html',''); initResizable(true); });  Ntrie_operations  CTnodeClass defining the structure of trie node and containing the methods to perform operations on them  NothersFor vector - Niterative_tree_traversals - CBinaryTreeDefines the functions associated with the binary tree - CNodeDefines the structure of a node of the tree - Nlru_cache - CLRUCacheLRU cache class - Npostfix_expression - CStackCreates an array to be used as stack for storing values - Nrecursive_tree_traversals - CBTBT used to make the entire structure of the binary tree and the functions associated with the binary tree - CNodeThe structure to hold Nodes of the tree + NCacheCache algorithm + CD_NodeNode for a doubly linked list with data, prev and next pointers + CLFUCacheLFUCache + Niterative_tree_traversals + CBinaryTreeDefines the functions associated with the binary tree + CNodeDefines the structure of a node of the tree + Nlru_cache + CLRUCacheLRU cache class + Npostfix_expression + CStackCreates an array to be used as stack for storing values + Nrecursive_tree_traversals + CBTBT used to make the entire structure of the binary tree and the functions associated with the binary tree + CNodeThe structure to hold Nodes of the tree  NprobabilityProbability algorithms  Ngeometric_dist  Cgeometric_distributionA class to model the geometric distribution diff --git a/annotated_dup.js b/annotated_dup.js index 3cb251954..6f403959f 100644 --- a/annotated_dup.js +++ b/annotated_dup.js @@ -122,6 +122,10 @@ 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" ] + ] ], [ "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" ], [ "Node", "d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node.html", "d2/d9a/structothers_1_1iterative__tree__traversals_1_1_node" ] diff --git a/classes.html b/classes.html index 38c6d2478..47ed1e4ea 100644 --- a/classes.html +++ b/classes.html @@ -120,7 +120,7 @@ $(function(){initNavTree('classes.html',''); initResizable(true); });
catalan_numbers
CircularLinkedList (operations_on_datastructures::circular_linked_list)
cll
Compare
compare
AyStarSearch::comparison_operator (machine_learning::aystar_search)
Complex
Convexhull (geometry::jarvis)
CycleCheck
D
-
DenseLayer (machine_learning::neural_network::layers)
double_linked_list
dsu
+
D_Node (others::Cache)
DenseLayer (machine_learning::neural_network::layers)
double_linked_list
dsu
E
EasterYearMonthDay
Edge
EightPuzzle (machine_learning::aystar_search)
Entry (double_hashing)
Entry (linear_probing)
Entry (quadratic_probing)
@@ -141,7 +141,7 @@ $(function(){initNavTree('classes.html',''); initResizable(true); });
Knn (machine_learning::k_nearest_neighbors)
L
-
large_number
link (data_structures::linked_list)
linkedlist
list (data_structures::linked_list)
list (data_structures::list_array)
list
ListNode
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
LowestCommonAncestor (graph)
LRUCache (others::lru_cache)
M
Matrix (divide_and_conquer::strassens_multiplication)
MinHeap
MinHeapNode
mst
diff --git a/d0/d6f/namespaceothers.html b/d0/d6f/namespaceothers.html index 690cdd57f..62715466a 100644 --- a/d0/d6f/namespaceothers.html +++ b/d0/d6f/namespaceothers.html @@ -105,6 +105,7 @@ $(function(){initNavTree('d0/d6f/namespaceothers.html','../../'); initResizable(
+Namespaces | Functions
others Namespace Reference
@@ -113,6 +114,12 @@ $(function(){initNavTree('d0/d6f/namespaceothers.html','../../'); initResizable(

for vector More...

+ + + + +

+Namespaces

namespace  Cache
 Cache algorithm.
 
@@ -125,8 +132,8 @@ Functions

Detailed Description

for vector

for vector

-

Other algorithms.

for std::unordered_map

+

Other algorithms.

for IO operations

for reverse for assert for I/O operations for stack

Other algorithms

diff --git a/d0/d6f/namespaceothers.js b/d0/d6f/namespaceothers.js index 92c2630c8..baf841bfa 100644 --- a/d0/d6f/namespaceothers.js +++ b/d0/d6f/namespaceothers.js @@ -1,5 +1,6 @@ var namespaceothers = [ + [ "Cache", "db/dde/namespaceothers_1_1_cache.html", "db/dde/namespaceothers_1_1_cache" ], [ "are_almost_equal", "d0/d6f/namespaceothers.html#aa17dc6d061dff34f6b9a610bc5e26703", null ], [ "kelvin_to_celsius", "d0/d6f/namespaceothers.html#a48677fae5d683070432b1a905722d9ec", null ] ]; \ No newline at end of file diff --git a/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph.map b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph.map new file mode 100644 index 000000000..e1baff9f2 --- /dev/null +++ b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph.map @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph.md5 b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph.md5 new file mode 100644 index 000000000..e26e027b1 --- /dev/null +++ b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph.md5 @@ -0,0 +1 @@ +6ac5b9d32a99a7471b8fdd6c74403344 \ No newline at end of file diff --git a/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph.svg b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph.svg new file mode 100644 index 000000000..2c311ba34 --- /dev/null +++ b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph.svg @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +others::Cache::LFUCache< K, V > + + +Node1 + + +others::Cache::LFUCache +< K, V > + + + + + +Node2 + + +std::unordered_map +< K, std::pair< others +::Cache::D_Node< K, V + > *, int > > + + + + + +Node2->Node1 + + + + + + node_map + + + +Node3 + + +K + + + + + +Node3->Node2 + + + + + + keys + + + +Node5 + + +others::Cache::D_Node +< K, V > + + + + + +Node3->Node5 + + + + + + data + + + +Node4 + + +std::pair< others:: +Cache::D_Node< K, V + > *, int > + + + + + +Node4->Node2 + + + + + + elements + + + +Node5->Node4 + + + + + + first_type + + + +Node7 + + +std::pair< others:: +Cache::D_Node< K, V + > *, others::Cache:: +D_Node< K, V > * > + + + + + +Node5->Node7 + + + + + + first_type +second_type + + + +Node6 + + +std::unordered_map +< int, std::pair< others +::Cache::D_Node< K, V > + *, others::Cache::D_Node +< K, V > * > > + + + + + +Node6->Node1 + + + + + + freq_map + + + +Node7->Node6 + + + + + + elements + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph_org.svg b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph_org.svg new file mode 100644 index 000000000..57ab5ac1c --- /dev/null +++ b/d4/d53/classothers_1_1_cache_1_1_l_f_u_cache__coll__graph_org.svg @@ -0,0 +1,170 @@ + + + + + + +others::Cache::LFUCache< K, V > + + +Node1 + + +others::Cache::LFUCache +< K, V > + + + + + +Node2 + + +std::unordered_map +< K, std::pair< others +::Cache::D_Node< K, V + > *, int > > + + + + + +Node2->Node1 + + + + + + node_map + + + +Node3 + + +K + + + + + +Node3->Node2 + + + + + + keys + + + +Node5 + + +others::Cache::D_Node +< K, V > + + + + + +Node3->Node5 + + + + + + data + + + +Node4 + + +std::pair< others:: +Cache::D_Node< K, V + > *, int > + + + + + +Node4->Node2 + + + + + + elements + + + +Node5->Node4 + + + + + + first_type + + + +Node7 + + +std::pair< others:: +Cache::D_Node< K, V + > *, others::Cache:: +D_Node< K, V > * > + + + + + +Node5->Node7 + + + + + + first_type +second_type + + + +Node6 + + +std::unordered_map +< int, std::pair< others +::Cache::D_Node< K, V > + *, others::Cache::D_Node +< K, V > * > > + + + + + +Node6->Node1 + + + + + + freq_map + + + +Node7->Node6 + + + + + + elements + + + 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 new file mode 100644 index 000000000..99f4bf590 --- /dev/null +++ b/d5/ddb/classothers_1_1_cache_1_1_d___node-members.html @@ -0,0 +1,126 @@ + + + + + + + +Algorithms_in_C++: Member List + + + + + + + + + + + + + + + + + +
+
+

Functions

bool are_almost_equal (double a, double b, double absolute_tolerance=0.0001)
+ + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+ + + + + + + + + + +
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
others::Cache::D_Node< T > Member List
+
+
+ +

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 >
+
+ + + + diff --git a/d6/dae/classothers_1_1lru__cache_1_1_l_r_u_cache.html b/d6/dae/classothers_1_1lru__cache_1_1_l_r_u_cache.html index df1fc3514..af637d1f7 100644 --- a/d6/dae/classothers_1_1lru__cache_1_1_l_r_u_cache.html +++ b/d6/dae/classothers_1_1lru__cache_1_1_l_r_u_cache.html @@ -146,7 +146,7 @@ uint64_t pageFrame  std::list< uint64_t > cache - Cache linked list (using the STL)
Cache linked list (using the STL)
  std::unordered_map< uint64_t, std::list< uint64_t >::iterator > pageMap diff --git a/d6/dca/lfu__cache_8cpp__incl.map b/d6/dca/lfu__cache_8cpp__incl.map new file mode 100644 index 000000000..5a561b332 --- /dev/null +++ b/d6/dca/lfu__cache_8cpp__incl.map @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/d6/dca/lfu__cache_8cpp__incl.md5 b/d6/dca/lfu__cache_8cpp__incl.md5 new file mode 100644 index 000000000..2f18aca1b --- /dev/null +++ b/d6/dca/lfu__cache_8cpp__incl.md5 @@ -0,0 +1 @@ +08f5951acd7232c48a62c9afc57379b1 \ No newline at end of file diff --git a/d6/dca/lfu__cache_8cpp__incl.svg b/d6/dca/lfu__cache_8cpp__incl.svg new file mode 100644 index 000000000..8b6fe3308 --- /dev/null +++ b/d6/dca/lfu__cache_8cpp__incl.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + +others/lfu_cache.cpp + + +Node1 + + +others/lfu_cache.cpp + + + + + +Node2 + + +cassert + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +iostream + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +unordered_map + + + + + +Node1->Node4 + + + + + + + + + + + + + diff --git a/d6/dca/lfu__cache_8cpp__incl_org.svg b/d6/dca/lfu__cache_8cpp__incl_org.svg new file mode 100644 index 000000000..c693b3016 --- /dev/null +++ b/d6/dca/lfu__cache_8cpp__incl_org.svg @@ -0,0 +1,75 @@ + + + + + + +others/lfu_cache.cpp + + +Node1 + + +others/lfu_cache.cpp + + + + + +Node2 + + +cassert + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +iostream + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +unordered_map + + + + + +Node1->Node4 + + + + + + + + diff --git a/d9/d65/lfu__cache_8cpp.html b/d9/d65/lfu__cache_8cpp.html new file mode 100644 index 000000000..23c47ab36 --- /dev/null +++ b/d9/d65/lfu__cache_8cpp.html @@ -0,0 +1,290 @@ + + + + + + + +Algorithms_in_C++: others/lfu_cache.cpp File Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
lfu_cache.cpp File Reference
+
+
+ +

Implementation for [LFU Cache] (https://en.wikipedia.org/wiki/Least_frequently_used) +More...

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

+Classes

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

+Namespaces

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

+Typedefs

+template<typename K , typename V >
using others::Cache::CacheNode = D_Node<std::pair<K, V>>
 
+ + + + + + + +

+Functions

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

Detailed Description

+

Implementation for [LFU Cache] (https://en.wikipedia.org/wiki/Least_frequently_used)

+

LFU discards the least frequently used value. if there are multiple items with the same minimum frequency then, the least recently used among them is discarded. Data structures used - doubly linked list and unordered_map(hash +map).

+

Hashmap maps the key to the address of the node of the linked list and its current usage frequency. If the element is accessed the element is removed from the linked list of the current frequency and added to the linked list of incremented frequency.

+

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

+
Author
Karan Sharma
+

Function Documentation

+ +

◆ main()

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

main function

+
Returns
0 on exit
+
301 {
+
302 test(); // run the self test implementation
+
303 return 0;
+
304}
+
static void test()
self test implementation
Definition lfu_cache.cpp:250
+
+Here is the call graph for this function:
+
+
+
+ +
+
+ +

◆ test()

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

self test implementation

+
Returns
void
+
250 {
+ +
252
+
253 // test the initial state of the cache
+
254 assert(cache.size() == 0);
+
255 assert(cache.capacity() == 5);
+
256 assert(cache.empty());
+
257
+
258 // test insertion in the cache
+
259 cache.put(1, 10);
+
260 cache.put(-2, 20);
+
261
+
262 // test the state of cache after inserting some items
+
263 assert(cache.size() == 2);
+
264 assert(cache.capacity() == 5);
+
265 assert(!cache.empty());
+
266
+
267 // test getting items from the cache
+
268 assert(cache.get(1) == 10);
+
269 assert(cache.get(-2) == 20);
+
270
+
271 cache.put(-3, -30);
+
272 cache.put(4, 40);
+
273 cache.put(5, -50);
+
274 cache.put(6, 60);
+
275
+
276 // test the state after inserting more items than the capacity
+
277 assert(cache.size() == 5);
+
278 assert(cache.capacity() == 5);
+
279 assert(!cache.empty());
+
280
+
281 // test retrieval of all items in the cache
+
282 assert(cache.get(1) == 10);
+
283 assert(cache.get(-2) == 20);
+
284
+
285 // fetching -3 throws runtime_error
+
286 // as -3 was evicted being the least frequently used
+
287 // when 6 was added
+
288 // assert(cache.get(-3) == -30);
+
289
+
290 assert(cache.get(4) == 40);
+
291 assert(cache.get(5) == -50);
+
292 assert(cache.get(6) == 60);
+
293
+
294 std::cout << "test - passed\n";
+
295}
+ +
LFUCache.
Definition lfu_cache.cpp:64
+
+Here is the call graph for this function:
+
+
+
+ +
+
+
+
+ + + + diff --git a/d9/d65/lfu__cache_8cpp.js b/d9/d65/lfu__cache_8cpp.js new file mode 100644 index 000000000..b5e36b383 --- /dev/null +++ b/d9/d65/lfu__cache_8cpp.js @@ -0,0 +1,7 @@ +var lfu__cache_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::LFUCache< K, V >", "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" ], + [ "main", "d9/d65/lfu__cache_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], + [ "test", "d9/d65/lfu__cache_8cpp.html#aa8dca7b867074164d5f45b0f3851269d", null ] +]; \ No newline at end of file diff --git a/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map b/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map new file mode 100644 index 000000000..baedf2a3c --- /dev/null +++ b/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.map @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 b/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 new file mode 100644 index 000000000..a4e7f9181 --- /dev/null +++ b/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.md5 @@ -0,0 +1 @@ +0591dc07f3e2271183514438a924765e \ No newline at end of file diff --git a/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg b/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg new file mode 100644 index 000000000..8c7d0e073 --- /dev/null +++ b/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg @@ -0,0 +1,271 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +test + + +Node1 + + +test + + + + + +Node2 + + +others::Cache::LFUCache +::capacity + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LFUCache +::empty + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +others::Cache::LFUCache::get + + + + + +Node1->Node4 + + + + + + + + +Node7 + + +others::Cache::LFUCache::put + + + + + +Node1->Node7 + + + + + + + + +Node9 + + +others::Cache::LFUCache +::size + + + + + +Node1->Node9 + + + + + + + + +Node5 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node4->Node5 + + + + + + + + +Node6 + + +others::Cache::LFUCache +::push + + + + + +Node5->Node6 + + + + + + + + +Node7->Node5 + + + + + + + + +Node7->Node6 + + + + + + + + +Node8 + + +others::Cache::LFUCache::pop + + + + + +Node7->Node8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg b/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg new file mode 100644 index 000000000..96f47300c --- /dev/null +++ b/d9/d65/lfu__cache_8cpp_aa8dca7b867074164d5f45b0f3851269d_cgraph_org.svg @@ -0,0 +1,188 @@ + + + + + + +test + + +Node1 + + +test + + + + + +Node2 + + +others::Cache::LFUCache +::capacity + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LFUCache +::empty + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +others::Cache::LFUCache::get + + + + + +Node1->Node4 + + + + + + + + +Node7 + + +others::Cache::LFUCache::put + + + + + +Node1->Node7 + + + + + + + + +Node9 + + +others::Cache::LFUCache +::size + + + + + +Node1->Node9 + + + + + + + + +Node5 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node4->Node5 + + + + + + + + +Node6 + + +others::Cache::LFUCache +::push + + + + + +Node5->Node6 + + + + + + + + +Node7->Node5 + + + + + + + + +Node7->Node6 + + + + + + + + +Node8 + + +others::Cache::LFUCache::pop + + + + + +Node7->Node8 + + + + + + + + diff --git a/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map b/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map new file mode 100644 index 000000000..bc9db1e6c --- /dev/null +++ b/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.map @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 b/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 new file mode 100644 index 000000000..9641dce67 --- /dev/null +++ b/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.md5 @@ -0,0 +1 @@ +d353b232a9a0af8fc1835fc904dbe96e \ No newline at end of file diff --git a/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg b/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg new file mode 100644 index 000000000..9e6a3f8c4 --- /dev/null +++ b/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +main + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LFUCache +::capacity + + + + + +Node2->Node3 + + + + + + + + +Node4 + + +others::Cache::LFUCache +::empty + + + + + +Node2->Node4 + + + + + + + + +Node5 + + +others::Cache::LFUCache::get + + + + + +Node2->Node5 + + + + + + + + +Node8 + + +others::Cache::LFUCache::put + + + + + +Node2->Node8 + + + + + + + + +Node10 + + +others::Cache::LFUCache +::size + + + + + +Node2->Node10 + + + + + + + + +Node6 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node5->Node6 + + + + + + + + +Node7 + + +others::Cache::LFUCache +::push + + + + + +Node6->Node7 + + + + + + + + +Node8->Node6 + + + + + + + + +Node8->Node7 + + + + + + + + +Node9 + + +others::Cache::LFUCache::pop + + + + + +Node8->Node9 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg b/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg new file mode 100644 index 000000000..6dfeed12c --- /dev/null +++ b/d9/d65/lfu__cache_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph_org.svg @@ -0,0 +1,206 @@ + + + + + + +main + + +Node1 + + +main + + + + + +Node2 + + +test + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LFUCache +::capacity + + + + + +Node2->Node3 + + + + + + + + +Node4 + + +others::Cache::LFUCache +::empty + + + + + +Node2->Node4 + + + + + + + + +Node5 + + +others::Cache::LFUCache::get + + + + + +Node2->Node5 + + + + + + + + +Node8 + + +others::Cache::LFUCache::put + + + + + +Node2->Node8 + + + + + + + + +Node10 + + +others::Cache::LFUCache +::size + + + + + +Node2->Node10 + + + + + + + + +Node6 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node5->Node6 + + + + + + + + +Node7 + + +others::Cache::LFUCache +::push + + + + + +Node6->Node7 + + + + + + + + +Node8->Node6 + + + + + + + + +Node8->Node7 + + + + + + + + +Node9 + + +others::Cache::LFUCache::pop + + + + + +Node8->Node9 + + + + + + + + diff --git a/db/d36/classothers_1_1_cache_1_1_l_f_u_cache-members.html b/db/d36/classothers_1_1_cache_1_1_l_f_u_cache-members.html new file mode 100644 index 000000000..afafec019 --- /dev/null +++ b/db/d36/classothers_1_1_cache_1_1_l_f_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::LFUCache< K, V > Member List
+
+
+ +

This is the complete list of members for others::Cache::LFUCache< K, V >, including all inherited members.

+ + + + + + + + + + + + + + + +
_capacityothers::Cache::LFUCache< K, V >private
capacity() constothers::Cache::LFUCache< K, V >inline
empty() constothers::Cache::LFUCache< K, V >inline
freq_mapothers::Cache::LFUCache< K, V >private
get(K key)others::Cache::LFUCache< K, V >inline
increase_frequency(std::pair< CacheNode< K, V > *, int > &p_node)others::Cache::LFUCache< K, V >inlineprivate
LFUCache(int _capacity)others::Cache::LFUCache< K, V >inlineexplicit
minFreqothers::Cache::LFUCache< K, V >private
node_mapothers::Cache::LFUCache< K, V >private
pop()others::Cache::LFUCache< K, V >inlineprivate
push(int freq, CacheNode< K, V > *node)others::Cache::LFUCache< K, V >inlineprivate
put(K key, V value)others::Cache::LFUCache< K, V >inline
size() constothers::Cache::LFUCache< K, V >inline
~LFUCache()others::Cache::LFUCache< K, V >inline
+
+ + + + diff --git a/db/dde/namespaceothers_1_1_cache.html b/db/dde/namespaceothers_1_1_cache.html new file mode 100644 index 000000000..4c1259356 --- /dev/null +++ b/db/dde/namespaceothers_1_1_cache.html @@ -0,0 +1,145 @@ + + + + + + + +Algorithms_in_C++: others::Cache Namespace Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
others::Cache Namespace Reference
+
+
+ +

Cache algorithm. +More...

+ + + + + + + + +

+Classes

class  D_Node
 Node for a doubly linked list with data, prev and next pointers. More...
 
class  LFUCache
 LFUCache. More...
 
+ + + + +

+Typedefs

+template<typename K , typename V >
using CacheNode = D_Node<std::pair<K, V>>
 
+

Detailed Description

+

Cache algorithm.

+
+
+ + + + diff --git a/db/dde/namespaceothers_1_1_cache.js b/db/dde/namespaceothers_1_1_cache.js new file mode 100644 index 000000000..9817e71e3 --- /dev/null +++ b/db/dde/namespaceothers_1_1_cache.js @@ -0,0 +1,5 @@ +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" ] +]; \ No newline at end of file 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 new file mode 100644 index 000000000..12eca7324 --- /dev/null +++ b/de/d21/classothers_1_1_cache_1_1_d___node.html @@ -0,0 +1,197 @@ + + + + + + + +Algorithms_in_C++: others::Cache::D_Node< T > Class Template Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
others::Cache::D_Node< T > Class Template Reference
+
+
+ +

Node for a doubly linked list with data, prev and next pointers. + More...

+
+Collaboration diagram for others::Cache::D_Node< T >:
+
+
+
[legend]
+ + + + +

+Public Member Functions

 D_Node (T data)
 
+ + + + + + + + + + +

+Public Attributes

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

Detailed Description

+
template<typename T>
+class others::Cache::D_Node< T >

Node for a doubly linked list with data, prev and next pointers.

+
Template Parameters
+ + +
Ttype of the data of the node
+
+
+

Constructor & Destructor Documentation

+ +

◆ D_Node()

+ +
+
+
+template<typename T >
+ + + + + +
+ + + + + + + +
others::Cache::D_Node< T >::D_Node (T data)
+
+inlineexplicit
+
+
51: data(data), prev(nullptr), next(nullptr) {}
+
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 new file mode 100644 index 000000000..c24cc15b6 --- /dev/null +++ b/de/d21/classothers_1_1_cache_1_1_d___node.js @@ -0,0 +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 ] +]; \ No newline at end of file diff --git a/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph.map b/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph.map new file mode 100644 index 000000000..82dcc1fb1 --- /dev/null +++ b/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph.md5 b/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph.md5 new file mode 100644 index 000000000..19377a789 --- /dev/null +++ b/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph.md5 @@ -0,0 +1 @@ +63edbfb406bc0ef38cc4583da9998fb4 \ No newline at end of file diff --git a/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph.svg b/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph.svg new file mode 100644 index 000000000..d408b1028 --- /dev/null +++ b/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + +others::Cache::D_Node< T > + + +Node1 + + +others::Cache::D_Node< T > + + + + + +Node2 + + +T + + + + + +Node2->Node1 + + + + + + data + + + + + + + + diff --git a/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph_org.svg b/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph_org.svg new file mode 100644 index 000000000..e4ec5e825 --- /dev/null +++ b/de/d6f/classothers_1_1_cache_1_1_d___node__coll__graph_org.svg @@ -0,0 +1,40 @@ + + + + + + +others::Cache::D_Node< T > + + +Node1 + + +others::Cache::D_Node< T > + + + + + +Node2 + + +T + + + + + +Node2->Node1 + + + + + + data + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html new file mode 100644 index 000000000..20e60eb44 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html @@ -0,0 +1,684 @@ + + + + + + + +Algorithms_in_C++: others::Cache::LFUCache< K, V > Class Template Reference + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
Algorithms_in_C++ 1.0.0 +
+
Set of algorithms implemented in C++.
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
others::Cache::LFUCache< K, V > Class Template Reference
+
+
+ +

LFUCache. + More...

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

+Public Member Functions

 LFUCache (int _capacity)
 Constructor, Initialize with minFreq and _capacity.
 
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 true if the cache is empty, false otherwise.
 
 ~LFUCache ()
 destructs the cache, iterates on the map and deletes every node present in the cache.
 
+ + + + + + + + + + +

+Private Member Functions

void push (int freq, CacheNode< K, V > *node)
 push the node at first position in the linked list of given frequency
 
void increase_frequency (std::pair< CacheNode< K, V > *, int > &p_node)
 increase the frequency of node and push it in the respective list.
 
void pop ()
 pop the last node in the least frequently used linked list
 
+ + + + + + + + + + + + + +

+Private Attributes

+std::unordered_map< K, std::pair< CacheNode< K, V > *, int > > node_map
 maps the key to the node address and frequency
 
+std::unordered_map< int, std::pair< CacheNode< K, V > *, CacheNode< K, V > * > > freq_map
 maps the frequency to doubly linked list
 
+int minFreq
 minimum frequency in the cache
 
+int _capacity
 maximum capacity of the cache
 
+

Detailed Description

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

LFUCache.

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

Constructor & Destructor Documentation

+ +

◆ LFUCache()

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

Constructor, Initialize with minFreq and _capacity.

+
Parameters
+ + +
_capacityTotal capacity of the cache.
+
+
+
+
int _capacity
maximum capacity of the cache
Definition lfu_cache.cpp:71
+
int minFreq
minimum frequency in the cache
Definition lfu_cache.cpp:70
+
+
+
+ +

◆ ~LFUCache()

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

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

+
235 {
+
236 auto it = node_map.begin();
+
237 while (it != node_map.end()) {
+
238 delete it->second.first;
+
239 ++it;
+
240 }
+
241 }
+
std::unordered_map< K, std::pair< CacheNode< K, V > *, int > > node_map
maps the key to the node address and frequency
Definition lfu_cache.cpp:66
+
+
+
+

Member Function Documentation

+ +

◆ capacity()

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

Returns the total capacity of the cache.

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

◆ empty()

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

returns true if the cache is empty, false otherwise.

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

◆ get()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
V others::Cache::LFUCache< 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
+
+
+
202 {
+
203 if (!node_map.count(key)) {
+
204 throw std::runtime_error("key is not present in the cache");
+
205 }
+
206
+
207 // increase the frequency and return the value
+
208 V value = node_map[key].first->data.second;
+ +
210 return value;
+
211 }
+
void increase_frequency(std::pair< CacheNode< K, V > *, int > &p_node)
increase the frequency of node and push it in the respective list.
Definition lfu_cache.cpp:109
+ +
+Here is the call graph for this function:
+
+
+
+ +
+
+ +

◆ increase_frequency()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
void others::Cache::LFUCache< K, V >::increase_frequency (std::pair< CacheNode< K, V > *, int > & p_node)
+
+inlineprivate
+
+ +

increase the frequency of node and push it in the respective list.

+
Parameters
+ + +
p_nodethe node to be updated
+
+
+
109 {
+
110 CacheNode<K, V> *node = p_node.first;
+
111 int freq = p_node.second;
+
112
+
113 std::pair<CacheNode<K, V> *, CacheNode<K, V> *> &p = freq_map[freq];
+
114
+
115 // if the given node is the only node in the list,
+
116 // then erase the frequency from map
+
117 // and increase minFreq by 1.
+
118 if (p.first == node && p.second == node) {
+
119 freq_map.erase(freq);
+
120 if (minFreq == freq) {
+
121 minFreq = freq + 1;
+
122 }
+
123 } else {
+
124 // remove the given node from current freq linked list
+
125 CacheNode<K, V> *prev = node->prev;
+
126 CacheNode<K, V> *next = node->next;
+
127 node->prev = nullptr;
+
128 node->next = nullptr;
+
129
+
130 if (prev) {
+
131 prev->next = next;
+
132 } else {
+
133 p.first = next;
+
134 }
+
135
+
136 if (next) {
+
137 next->prev = prev;
+
138 } else {
+
139 p.second = prev;
+
140 }
+
141 }
+
142 push(freq + 1, node);
+
143 ++p_node.second;
+
144 }
+
std::unordered_map< int, std::pair< CacheNode< K, V > *, CacheNode< K, V > * > > freq_map
maps the frequency to doubly linked list
Definition lfu_cache.cpp:68
+
void push(int freq, CacheNode< K, V > *node)
push the node at first position in the linked list of given frequency
Definition lfu_cache.cpp:88
+
T next(T... args)
+ +
T prev(T... args)
+
Definition binary_search_tree.cpp:11
+
+Here is the call graph for this function:
+
+
+
+ +
+
+ +

◆ pop()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + +
void others::Cache::LFUCache< K, V >::pop ()
+
+inlineprivate
+
+ +

pop the last node in the least frequently used linked list

+
149 {
+
150 std::pair<CacheNode<K, V> *, CacheNode<K, V> *> &p = freq_map[minFreq];
+
151
+
152 // if there is only one node
+
153 // remove the node and erase
+
154 // the frequency from freq_map
+
155 if (p.first == p.second) {
+
156 delete p.first;
+
157 freq_map.erase(minFreq);
+
158 return;
+
159 }
+
160
+
161 // remove the last node in the linked list
+
162 CacheNode<K, V> *temp = p.second;
+
163 p.second = temp->prev;
+
164 p.second->next = nullptr;
+
165 delete temp;
+
166 }
+
+
+
+ +

◆ push()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + + + + + +
void others::Cache::LFUCache< K, V >::push (int freq,
CacheNode< K, V > * node )
+
+inlineprivate
+
+ +

push the node at first position in the linked list of given frequency

+
Parameters
+ + + +
freqthe frequency mapping to the linked list where node should be pushed.
nodenode to be pushed to the linked list.
+
+
+
88 {
+
89 // if freq is not present, then make a new list with node as the head as
+
90 // well as tail.
+
91 if (!freq_map.count(freq)) {
+
92 freq_map[freq] = {node, node};
+
93 return;
+
94 }
+
95
+
96 std::pair<CacheNode<K, V> *, CacheNode<K, V> *> &p = freq_map[freq];
+
97
+
98 // insert the node at the beginning of the linked list and update the
+
99 // head.
+
100 p.first->prev = node;
+
101 node->next = p.first;
+
102 p.first = node;
+
103 }
+
struct node { int data; int height; struct node *left; struct node *right;} node
for std::queue
Definition avltree.cpp:13
+
+
+
+ +

◆ put()

+ +
+
+
+template<typename K , typename V >
+ + + + + +
+ + + + + + + + + + + +
void others::Cache::LFUCache< 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
+
+
+
174 {
+
175 // update the value if key already exists
+
176 if (node_map.count(key)) {
+
177 node_map[key].first->data.second = value;
+ +
179 return;
+
180 }
+
181
+
182 // if the cache is full
+
183 // remove the least frequently used item
+
184 if (node_map.size() == _capacity) {
+
185 node_map.erase(freq_map[minFreq].second->data.first);
+
186 pop();
+
187 }
+
188
+
189 // insert the new node and set minFreq to 1
+
190 CacheNode<K, V> *node = new CacheNode<K, V>({key, value});
+
191 node_map[key] = {node, 1};
+
192 minFreq = 1;
+
193 push(1, node);
+
194 }
+
void pop()
pop the last node in the least frequently used linked list
Definition lfu_cache.cpp:149
+
+Here is the call graph for this function:
+
+
+
+ +
+
+ +

◆ size()

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

Returns the number of items present in the cache.

+
Returns
number of items in the cache
+
217{ return node_map.size(); }
+
+
+
+
The documentation for this class was generated from the following file: +
+
+ + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.js b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.js new file mode 100644 index 000000000..d13df9feb --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.js @@ -0,0 +1,17 @@ +var classothers_1_1_cache_1_1_l_f_u_cache = +[ + [ "LFUCache", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#affd7776c246caa2d0f92fd8616f6e5dc", null ], + [ "~LFUCache", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#a8857531ecc8ed2e36868e267148eff36", null ], + [ "capacity", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#ac27c9076377cbed2a2acc45a189fed2c", null ], + [ "empty", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#a68e1be0a3e0a6478aa35f04000e0e9b0", null ], + [ "get", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#a58e37d3713f28d36abbb8cdf6c432781", null ], + [ "increase_frequency", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#a16a25c102554c5653721a5112ef676c9", null ], + [ "pop", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#ab3561ab204754295199f9566924f7e69", null ], + [ "push", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#adad4ab43141fb8ba43facd3a71e07047", null ], + [ "put", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#af6f8e5a66a45436b490dfe015ff8866e", null ], + [ "size", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#adbfb2ef7358423fdf1f49d410f55f195", null ], + [ "_capacity", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#a3acc10e6bb67d9d9c4187f625723e6c5", null ], + [ "freq_map", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#aba5d59d0f6ab0c0d30a92551ca5a05f2", null ], + [ "minFreq", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#a6de844d1589a809239cc07752f311285", null ], + [ "node_map", "df/d8f/classothers_1_1_cache_1_1_l_f_u_cache.html#ac7684879e2e5da3d8bc5b1699ee42d35", null ] +]; \ No newline at end of file diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph.map b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph.map new file mode 100644 index 000000000..1cf680f50 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph.map @@ -0,0 +1,5 @@ + + + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph.md5 b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph.md5 new file mode 100644 index 000000000..67ab39f10 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph.md5 @@ -0,0 +1 @@ +136e5b2fde508fd9779a8e62e4f72912 \ No newline at end of file diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph.svg b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph.svg new file mode 100644 index 000000000..7450e45b2 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + +others::Cache::LFUCache::increase_frequency + + +Node1 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node2 + + +others::Cache::LFUCache +::push + + + + + +Node1->Node2 + + + + + + + + + + + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph_org.svg b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph_org.svg new file mode 100644 index 000000000..dc4fed684 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a16a25c102554c5653721a5112ef676c9_cgraph_org.svg @@ -0,0 +1,41 @@ + + + + + + +others::Cache::LFUCache::increase_frequency + + +Node1 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node2 + + +others::Cache::LFUCache +::push + + + + + +Node1->Node2 + + + + + + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph.map b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph.map new file mode 100644 index 000000000..38f488886 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph.map @@ -0,0 +1,7 @@ + + + + + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph.md5 b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph.md5 new file mode 100644 index 000000000..7860c59f0 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph.md5 @@ -0,0 +1 @@ +a478dd2129b44698d51017d165ed8e6b \ No newline at end of file diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph.svg b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph.svg new file mode 100644 index 000000000..8b4346172 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + +others::Cache::LFUCache::get + + +Node1 + + +others::Cache::LFUCache::get + + + + + +Node2 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LFUCache +::push + + + + + +Node2->Node3 + + + + + + + + + + + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph_org.svg b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph_org.svg new file mode 100644 index 000000000..c7ca8ce15 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_a58e37d3713f28d36abbb8cdf6c432781_cgraph_org.svg @@ -0,0 +1,59 @@ + + + + + + +others::Cache::LFUCache::get + + +Node1 + + +others::Cache::LFUCache::get + + + + + +Node2 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LFUCache +::push + + + + + +Node2->Node3 + + + + + + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph.map b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph.map new file mode 100644 index 000000000..30a25279c --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph.map @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph.md5 b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph.md5 new file mode 100644 index 000000000..087ab199a --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph.md5 @@ -0,0 +1 @@ +2f5e8422a3e70831f5f71798302110cc \ No newline at end of file diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph.svg b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph.svg new file mode 100644 index 000000000..3b4fbe19c --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph.svg @@ -0,0 +1,169 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +others::Cache::LFUCache::put + + +Node1 + + +others::Cache::LFUCache::put + + + + + +Node2 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LFUCache +::push + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +others::Cache::LFUCache::pop + + + + + +Node1->Node4 + + + + + + + + +Node2->Node3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph_org.svg b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph_org.svg new file mode 100644 index 000000000..0c6694ad8 --- /dev/null +++ b/df/d8f/classothers_1_1_cache_1_1_l_f_u_cache_af6f8e5a66a45436b490dfe015ff8866e_cgraph_org.svg @@ -0,0 +1,86 @@ + + + + + + +others::Cache::LFUCache::put + + +Node1 + + +others::Cache::LFUCache::put + + + + + +Node2 + + +others::Cache::LFUCache +::increase_frequency + + + + + +Node1->Node2 + + + + + + + + +Node3 + + +others::Cache::LFUCache +::push + + + + + +Node1->Node3 + + + + + + + + +Node4 + + +others::Cache::LFUCache::pop + + + + + +Node1->Node4 + + + + + + + + +Node2->Node3 + + + + + + + + diff --git a/dir_9510827d0b234b3cc54b29892f217477.html b/dir_9510827d0b234b3cc54b29892f217477.html index bcafdb1db..ca268f8a1 100644 --- a/dir_9510827d0b234b3cc54b29892f217477.html +++ b/dir_9510827d0b234b3cc54b29892f217477.html @@ -137,6 +137,9 @@ Files  kelvin_to_celsius.cpp  Conversion from Kelvin to Celsius degrees.
  + lfu_cache.cpp + Implementation for [LFU Cache] (https://en.wikipedia.org/wiki/Least_frequently_used)
 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).
  diff --git a/dir_9510827d0b234b3cc54b29892f217477.js b/dir_9510827d0b234b3cc54b29892f217477.js index d7d4364e8..3dd46e444 100644 --- a/dir_9510827d0b234b3cc54b29892f217477.js +++ b/dir_9510827d0b234b3cc54b29892f217477.js @@ -9,6 +9,7 @@ var dir_9510827d0b234b3cc54b29892f217477 = [ "iterative_tree_traversals.cpp", "d8/d90/iterative__tree__traversals_8cpp.html", "d8/d90/iterative__tree__traversals_8cpp" ], [ "kadanes3.cpp", "de/dcd/kadanes3_8cpp.html", "de/dcd/kadanes3_8cpp" ], [ "kelvin_to_celsius.cpp", "db/d6b/kelvin__to__celsius_8cpp.html", "db/d6b/kelvin__to__celsius_8cpp" ], + [ "lfu_cache.cpp", "d9/d65/lfu__cache_8cpp.html", "d9/d65/lfu__cache_8cpp" ], [ "lru_cache.cpp", "d3/db3/lru__cache_8cpp.html", "d3/db3/lru__cache_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" ], diff --git a/doxygen_crawl.html b/doxygen_crawl.html index 093ef54bd..1237e3165 100644 --- a/doxygen_crawl.html +++ b/doxygen_crawl.html @@ -233,6 +233,7 @@ + @@ -592,6 +593,11 @@ + + + + + @@ -2748,6 +2754,9 @@ + + + @@ -3264,6 +3273,7 @@ + @@ -3688,6 +3698,10 @@ + + + + @@ -3922,6 +3936,21 @@ + + + + + + + + + + + + + + + diff --git a/files.html b/files.html index dd730239a..3e47a8a2c 100644 --- a/files.html +++ b/files.html @@ -343,20 +343,21 @@ N)\) time, with precision fixed using iterative_tree_traversals.cppIterative version of Preorder, Postorder, and preorder [Traversal of the Tree] (https://en.wikipedia.org/wiki/Tree_traversal)  kadanes3.cppEfficient implementation for maximum contiguous subarray sum by Kadane's algorithm  kelvin_to_celsius.cppConversion from Kelvin to Celsius degrees - 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() + lfu_cache.cppImplementation for [LFU Cache] (https://en.wikipedia.org/wiki/Least_frequently_used) + 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()   physics  ground_to_ground_projectile_motion.cppGround to ground projectile motion equation implementations   probability diff --git a/functions.html b/functions.html index e68cae852..c98376b6a 100644 --- a/functions.html +++ b/functions.html @@ -109,6 +109,7 @@ $(function(){initNavTree('functions.html',''); initResizable(true); });

- _ -