Documentation for af6e2c8991

This commit is contained in:
realstealthninja
2026-09-21 04:13:18 +00:00
parent fa852a6801
commit cc04e74d11
2789 changed files with 66741 additions and 46802 deletions

View File

@@ -4,7 +4,7 @@
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="generator" content="Doxygen 1.18.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TheAlgorithms/C++: others/lru_cache2.cpp Source File</title>
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
@@ -23,22 +23,6 @@
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/javascript">
window.MathJax = {
options: {
ignoreHtmlClass: 'tex2jax_ignore',
processHtmlClass: 'tex2jax_process'
},
loader: {
load: ['[tex]/ams']
},
tex: {
macros: {},
packages: ['base','configmacros','ams']
}
};
</script>
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
</head>
@@ -59,22 +43,47 @@ window.MathJax = {
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<!-- Generated by Doxygen 1.18.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
let searchBox = new SearchBox("searchBox", "../../search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
document.addEventListener('DOMContentLoaded', codefold.init);
</script>
<script type="application/json" id="doxygen-config">
{
"relPath": "../../",
"generateTreeView": true,
"searchEngine": true,
"serverBasedSearch": false,
"disableIndex": false,
"dynamicMenus": true,
"fullSidebar": false
}
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('../../',true,false,'search.php','Search',true);
$(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<div id="main-nav-mobile">
<div class="sm sm-dox"><input id="main-menu-state" type="checkbox"/>
<label class="main-menu-btn" for="main-menu-state">
<span class="main-menu-btn-icon"></span> Toggle main menu visibility</label>
<span id="searchBoxPos1"></span>
</div>
</div><!-- main-nav-mobile -->
<div id="main-nav">
<ul class="sm sm-dox" id="main-menu">
<li id="searchBoxPos2">
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<span id="MSearchSelect" class="search-icon"><span class="search-icon-dropdown"></span></span>
<input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><div id="MSearchCloseImg" class="close-icon"></div></a>
</span>
</div>
</li>
</ul>
</div><!-- main-nav -->
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
@@ -82,20 +91,16 @@ $(function() {
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
<div id="splitbar" class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(function(){initNavTree('dc/daa/lru__cache2_8cpp_source.html','../../',''); });
document.addEventListener('DOMContentLoaded',() => { initNavTree('dc/daa/lru__cache2_8cpp_source.html','../../',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<div id="MSearchSelectWindow">
</div>
<!-- iframe showing the search results (closed by default) -->
@@ -206,8 +211,8 @@ $(function(){initNavTree('dc/daa/lru__cache2_8cpp_source.html','../../',''); });
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span> }</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> </div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> CacheNode&lt;K, V&gt; *temp = <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100">tail</a>;</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100">tail</a> = <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100">tail</a>-&gt;prev;</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100">tail</a>-&gt;next = <span class="keyword">nullptr</span>;</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span> <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100">tail</a> = <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100">tail</a>-&gt;<a class="code hl_variable" href="../../de/d21/classothers_1_1_cache_1_1_d___node.html#a19e954cbb710ea8318bcb6aaef78e2d5">prev</a>;</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span> <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100">tail</a>-&gt;<a class="code hl_variable" href="../../de/d21/classothers_1_1_cache_1_1_d___node.html#a0043eb287c54b3b2fb91ce354878a7bd">next</a> = <span class="keyword">nullptr</span>;</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> <span class="keyword">delete</span> temp;</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span> }</div>
</div>
@@ -225,7 +230,7 @@ $(function(){initNavTree('dc/daa/lru__cache2_8cpp_source.html','../../',''); });
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> <span class="comment">// if the cache is full</span></div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno"> 154</span> <span class="comment">// remove the least recently used item</span></div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno"> 155</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a8dab0f69410484f772946befd24cc3c5">node_map</a>.size() == <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#af34bb8b8eaa34cc499b4fed30b9d05fc">_capacity</a>) {</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a8dab0f69410484f772946befd24cc3c5">node_map</a>.erase(<a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100">tail</a>-&gt;data.first);</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno"> 156</span> <a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a8dab0f69410484f772946befd24cc3c5">node_map</a>.erase(<a class="code hl_variable" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#a448121f391a71f4cf88c3cb6c4cf3100">tail</a>-&gt;<a class="code hl_variable" href="../../de/d21/classothers_1_1_cache_1_1_d___node.html#a8902e7ff872fa3c80fe6ce5f5cf5cc75">data</a>.first);</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"> 157</span> <a class="code hl_function" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#ab211a4be58491bf11834cae88a0c44f7">pop_back</a>();</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"> 158</span> }</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno"> 159</span> </div>
@@ -270,7 +275,7 @@ $(function(){initNavTree('dc/daa/lru__cache2_8cpp_source.html','../../',''); });
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno"> 214</span>} <span class="comment">// namespace others</span></div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno"> 215</span></div>
<div class="foldopen" id="foldopen00220" data-start="{" data-end="}">
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno"><a class="line" href="../../dc/daa/lru__cache2_8cpp.html#aa8dca7b867074164d5f45b0f3851269d"> 220</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../dc/daa/lru__cache2_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>() {</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno"><a class="line" href="../../dc/daa/lru__cache2_8cpp.html#aa8dca7b867074164d5f45b0f3851269d"> 220</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../d6/d2c/caesar__cipher_8cpp.html#ae1a3968e7947464bee7714f6d43b7002">test</a>() {</div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno"> 221</span> <a class="code hl_class" href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html">others::Cache::LRUCache&lt;int, int&gt;</a> cache(5);</div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno"> 222</span> </div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno"> 223</span> <span class="comment">// test the initial state of the cache</span></div>
@@ -322,11 +327,12 @@ $(function(){initNavTree('dc/daa/lru__cache2_8cpp_source.html','../../',''); });
</div>
<div class="line"><a id="l00269" name="l00269"></a><span class="lineno"> 269</span></div>
<div class="foldopen" id="foldopen00274" data-start="{" data-end="}">
<div class="line"><a id="l00274" name="l00274"></a><span class="lineno"><a class="line" href="../../dc/daa/lru__cache2_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"> 274</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../dc/daa/lru__cache2_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
<div class="line"><a id="l00275" name="l00275"></a><span class="lineno"> 275</span> <a class="code hl_function" href="../../dc/daa/lru__cache2_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a>(); <span class="comment">// run the self test implementation</span></div>
<div class="line"><a id="l00274" name="l00274"></a><span class="lineno"><a class="line" href="../../dc/daa/lru__cache2_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"> 274</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../dd/d1e/generate__parentheses_8cpp.html#gae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
<div class="line"><a id="l00275" name="l00275"></a><span class="lineno"> 275</span> <a class="code hl_function" href="../../d6/d2c/caesar__cipher_8cpp.html#ae1a3968e7947464bee7714f6d43b7002">test</a>(); <span class="comment">// run the self test implementation</span></div>
<div class="line"><a id="l00276" name="l00276"></a><span class="lineno"> 276</span> <span class="keywordflow">return</span> 0;</div>
<div class="line"><a id="l00277" name="l00277"></a><span class="lineno"> 277</span>}</div>
</div>
<div class="ttc" id="acaesar__cipher_8cpp_html_ae1a3968e7947464bee7714f6d43b7002"><div class="ttname"><a href="../../d6/d2c/caesar__cipher_8cpp.html#ae1a3968e7947464bee7714f6d43b7002">test</a></div><div class="ttdeci">void test()</div><div class="ttdef"><b>Definition</b> <a href="../../d6/d2c/caesar__cipher_8cpp_source.html#l00100">caesar_cipher.cpp:100</a></div></div>
<div class="ttc" id="aclassothers_1_1_cache_1_1_d___node_html"><div class="ttname"><a href="../../de/d21/classothers_1_1_cache_1_1_d___node.html">others::Cache::D_Node</a></div><div class="ttdoc">Node for a doubly linked list with data, prev and next pointers.</div><div class="ttdef"><b>Definition</b> <a href="../../d9/d65/lfu__cache_8cpp_source.html#l00045">lfu_cache.cpp:45</a></div></div>
<div class="ttc" id="aclassothers_1_1_cache_1_1_d___node_html_a0043eb287c54b3b2fb91ce354878a7bd"><div class="ttname"><a href="../../de/d21/classothers_1_1_cache_1_1_d___node.html#a0043eb287c54b3b2fb91ce354878a7bd">others::Cache::D_Node::next</a></div><div class="ttdeci">D_Node&lt; T &gt; * next</div><div class="ttdoc">next node in the doubly linked list</div><div class="ttdef"><b>Definition</b> <a href="../../d9/d65/lfu__cache_8cpp_source.html#l00049">lfu_cache.cpp:49</a></div></div>
<div class="ttc" id="aclassothers_1_1_cache_1_1_d___node_html_a19e954cbb710ea8318bcb6aaef78e2d5"><div class="ttname"><a href="../../de/d21/classothers_1_1_cache_1_1_d___node.html#a19e954cbb710ea8318bcb6aaef78e2d5">others::Cache::D_Node::prev</a></div><div class="ttdeci">D_Node&lt; T &gt; * prev</div><div class="ttdoc">previous node in the doubly linked list</div><div class="ttdef"><b>Definition</b> <a href="../../d9/d65/lfu__cache_8cpp_source.html#l00048">lfu_cache.cpp:48</a></div></div>
@@ -346,8 +352,7 @@ $(function(){initNavTree('dc/daa/lru__cache2_8cpp_source.html','../../',''); });
<div class="ttc" id="aclassothers_1_1_cache_1_1_l_r_u_cache_html_ad022d494b40f82417340b113445e79a4"><div class="ttname"><a href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#ad022d494b40f82417340b113445e79a4">others::Cache::LRUCache::make_recent</a></div><div class="ttdeci">void make_recent(CacheNode&lt; K, V &gt; *node_ptr)</div><div class="ttdoc">move the existing node in the list to the beginning of the list.</div><div class="ttdef"><b>Definition</b> <a href="#l00099">lru_cache2.cpp:99</a></div></div>
<div class="ttc" id="aclassothers_1_1_cache_1_1_l_r_u_cache_html_af34bb8b8eaa34cc499b4fed30b9d05fc"><div class="ttname"><a href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#af34bb8b8eaa34cc499b4fed30b9d05fc">others::Cache::LRUCache::_capacity</a></div><div class="ttdeci">std::uint32_t _capacity</div><div class="ttdoc">maximum capacity of the cache</div><div class="ttdef"><b>Definition</b> <a href="#l00064">lru_cache2.cpp:64</a></div></div>
<div class="ttc" id="aclassothers_1_1_cache_1_1_l_r_u_cache_html_af8edfe5a7def5d5b846463041c33136a"><div class="ttname"><a href="../../d8/d2e/classothers_1_1_cache_1_1_l_r_u_cache.html#af8edfe5a7def5d5b846463041c33136a">others::Cache::LRUCache::capacity</a></div><div class="ttdeci">int capacity() const</div><div class="ttdoc">Returns the total capacity of the cache.</div><div class="ttdef"><b>Definition</b> <a href="#l00193">lru_cache2.cpp:193</a></div></div>
<div class="ttc" id="alru__cache2_8cpp_html_aa8dca7b867074164d5f45b0f3851269d"><div class="ttname"><a href="../../dc/daa/lru__cache2_8cpp.html#aa8dca7b867074164d5f45b0f3851269d">test</a></div><div class="ttdeci">static void test()</div><div class="ttdoc">self test implementations</div><div class="ttdef"><b>Definition</b> <a href="#l00220">lru_cache2.cpp:220</a></div></div>
<div class="ttc" id="alru__cache2_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../dc/daa/lru__cache2_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdoc">main function</div><div class="ttdef"><b>Definition</b> <a href="#l00274">lru_cache2.cpp:274</a></div></div>
<div class="ttc" id="agenerate__parentheses_8cpp_html_gae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../dd/d1e/generate__parentheses_8cpp.html#gae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdoc">Main function.</div><div class="ttdef"><b>Definition</b> <a href="../../dd/d1e/generate__parentheses_8cpp_source.html#l00110">generate_parentheses.cpp:110</a></div></div>
<div class="ttc" id="anamespaceothers_1_1_cache_html"><div class="ttname"><a href="../../db/dde/namespaceothers_1_1_cache.html">others::Cache</a></div><div class="ttdoc">Cache algorithm.</div><div class="ttdef"><b>Definition</b> <a href="../../d9/d65/lfu__cache_8cpp_source.html#l00037">lfu_cache.cpp:37</a></div></div>
<div class="ttc" id="anamespaceothers_html"><div class="ttname"><a href="../../d0/d6f/namespaceothers.html">others</a></div><div class="ttdoc">for vector</div></div>
</div><!-- fragment --></div><!-- contents -->
@@ -356,8 +361,8 @@ $(function(){initNavTree('dc/daa/lru__cache2_8cpp_source.html','../../',''); });
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a href="../../dir_9510827d0b234b3cc54b29892f217477.html">others</a></li><li class="navelem"><a href="../../dc/daa/lru__cache2_8cpp.html">lru_cache2.cpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
<li class="navelem"><b>others</b></li><li class="navelem"><a href="../../dc/daa/lru__cache2_8cpp.html">lru_cache2.cpp</a></li>
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.18.0 </li>
</ul>
</div>
</body>