Documentation for 85721be69b

This commit is contained in:
github-actions
2021-10-14 18:44:08 +00:00
parent 135b946a16
commit 4563c5bd6b
61 changed files with 1516 additions and 1115 deletions

View File

@@ -181,7 +181,7 @@ const size_type&#160;</td><td class="memItemRight" valign="bottom"><b>_windowSiz
</table>
</dd>
</dl>
<div class="fragment"><div class="line"><a id="l00122" name="l00122"></a><span class="lineno"> 122</span>: <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aafda847b152684578dab891e5268d750">_windowSize</a>(windowSize){};</div>
<div class="fragment"><div class="line"><a id="l00123" name="l00123"></a><span class="lineno"> 123</span>: <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aafda847b152684578dab891e5268d750">_windowSize</a>(windowSize){};</div>
<div class="ttc" id="aclassprobability_1_1windowed__median_1_1_windowed_median_html_aafda847b152684578dab891e5268d750"><div class="ttname"><a href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aafda847b152684578dab891e5268d750">probability::windowed_median::WindowedMedian::_windowSize</a></div><div class="ttdeci">const size_type _windowSize</div><div class="ttdoc">sliding window size</div><div class="ttdef"><b>Definition:</b> windowed_median.cpp:57</div></div>
</div><!-- fragment -->
</div>
@@ -233,16 +233,17 @@ const size_type&#160;</td><td class="memItemRight" valign="bottom"><b>_windowSiz
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> }</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span><span class="comment"></span> </div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span><span class="comment"> /// However, if the erased value is on the right branch or the median</span></div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span><span class="comment"> /// itself, and the number of elements is odd, the new median will be the</span></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span><span class="comment"> /// left child of the current one</span></div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span><span class="comment"> /// itself, and the number of elements is odd, the new median will be</span></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span><span class="comment"> /// the left child of the current one</span></div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span><span class="comment"></span> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (value &gt;= *<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a55ae3543a76045dffcb5ec7904a32a20">_itMedian</a> &amp;&amp; sz % 2 != 0) {</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno"> 109</span> --<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a55ae3543a76045dffcb5ec7904a32a20">_itMedian</a>; <span class="comment">// O(1) - traversing one step to the left child</span></div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno"> 110</span> }</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno"> 111</span><span class="comment"></span> </div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span><span class="comment"> /// Find the (first) position of the value we want to erase, and erase it</span></div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span><span class="comment"></span> <span class="keyword">const</span> <span class="keyword">auto</span> it = <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aacd76f078632faee1a8788d031e6c2de">_sortedValues</a>.find(value); <span class="comment">// O(logN)</span></div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span> <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aacd76f078632faee1a8788d031e6c2de">_sortedValues</a>.erase(it); <span class="comment">// O(logN)</span></div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> }</div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno"> 112</span><span class="comment"> /// Find the (first) position of the value we want to erase, and erase</span></div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"> 113</span><span class="comment"> /// it</span></div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"> 114</span><span class="comment"></span> <span class="keyword">const</span> <span class="keyword">auto</span> it = <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aacd76f078632faee1a8788d031e6c2de">_sortedValues</a>.find(value); <span class="comment">// O(logN)</span></div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aacd76f078632faee1a8788d031e6c2de">_sortedValues</a>.erase(it); <span class="comment">// O(logN)</span></div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> }</div>
<div class="ttc" id="aclassprobability_1_1windowed__median_1_1_windowed_median_html_a55ae3543a76045dffcb5ec7904a32a20"><div class="ttname"><a href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a55ae3543a76045dffcb5ec7904a32a20">probability::windowed_median::WindowedMedian::_itMedian</a></div><div class="ttdeci">std::multiset&lt; int &gt;::const_iterator _itMedian</div><div class="ttdef"><b>Definition:</b> windowed_median.cpp:62</div></div>
<div class="ttc" id="aclassprobability_1_1windowed__median_1_1_windowed_median_html_aacd76f078632faee1a8788d031e6c2de"><div class="ttname"><a href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aacd76f078632faee1a8788d031e6c2de">probability::windowed_median::WindowedMedian::_sortedValues</a></div><div class="ttdeci">std::multiset&lt; int &gt; _sortedValues</div><div class="ttdef"><b>Definition:</b> windowed_median.cpp:59</div></div>
</div><!-- fragment -->
@@ -274,12 +275,12 @@ const size_type&#160;</td><td class="memItemRight" valign="bottom"><b>_windowSiz
<p>Gets the median of the values in the sliding window. </p>
<dl class="section return"><dt>Returns</dt><dd>Median of sliding window. For even window size return the average between the two values in the middle </dd></dl>
<p >O(1)</p>
<div class="fragment"><div class="line"><a id="l00147" name="l00147"></a><span class="lineno"> 147</span> {</div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aacd76f078632faee1a8788d031e6c2de">_sortedValues</a>.size() % 2 != 0) {</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> <span class="keywordflow">return</span> *<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a55ae3543a76045dffcb5ec7904a32a20">_itMedian</a>; <span class="comment">// O(1)</span></div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> }</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> <span class="keywordflow">return</span> 0.5f * *<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a55ae3543a76045dffcb5ec7904a32a20">_itMedian</a> + 0.5f * *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/next.html">next</a>(<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a55ae3543a76045dffcb5ec7904a32a20">_itMedian</a>); <span class="comment">/// O(1)</span></div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> }</div>
<div class="fragment"><div class="line"><a id="l00148" name="l00148"></a><span class="lineno"> 148</span> {</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"> 149</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aacd76f078632faee1a8788d031e6c2de">_sortedValues</a>.size() % 2 != 0) {</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno"> 150</span> <span class="keywordflow">return</span> *<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a55ae3543a76045dffcb5ec7904a32a20">_itMedian</a>; <span class="comment">// O(1)</span></div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"> 151</span> }</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno"> 152</span> <span class="keywordflow">return</span> 0.5f * *<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a55ae3543a76045dffcb5ec7904a32a20">_itMedian</a> + 0.5f * *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/next.html">next</a>(<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a55ae3543a76045dffcb5ec7904a32a20">_itMedian</a>); <span class="comment">/// O(1)</span></div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno"> 153</span> }</div>
<div class="ttc" id="anext_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/iterator/next.html">std::next</a></div><div class="ttdeci">T next(T... args)</div></div>
</div><!-- fragment -->
</div>
@@ -312,18 +313,18 @@ const size_type&#160;</td><td class="memItemRight" valign="bottom"><b>_windowSiz
<p >Sort window - O(NlogN)</p>
<p >Find value in the middle - O(N)</p>
<p >O(N)</p>
<div class="fragment"><div class="line"><a id="l00160" name="l00160"></a><span class="lineno"> 160</span> {</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> <span class="keyword">auto</span> window = <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">_window</a>;</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> window.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/sort.html">sort</a>(); <span class="comment">/// Sort window - O(NlogN)</span></div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> <span class="keyword">auto</span> median =</div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/next.html">next</a>(window.begin(),</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span> window.size() / 2); <span class="comment">/// Find value in the middle - O(N)</span></div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> <span class="keywordflow">if</span> (window.size() % 2 != 0) {</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span> <span class="keywordflow">return</span> median;</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> }</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> <span class="keywordflow">return</span> 0.5f * median +</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> 0.5f * *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/next.html">next</a>(window.begin(), window.size() / 2 - 1); <span class="comment">/// O(N)</span></div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> }</div>
<div class="fragment"><div class="line"><a id="l00161" name="l00161"></a><span class="lineno"> 161</span> {</div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno"> 162</span> <span class="keyword">auto</span> window = <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">_window</a>;</div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno"> 163</span> window.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/sort.html">sort</a>(); <span class="comment">/// Sort window - O(NlogN)</span></div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno"> 164</span> <span class="keyword">auto</span> median =</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"> 165</span> *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/next.html">next</a>(window.begin(),</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno"> 166</span> window.size() / 2); <span class="comment">/// Find value in the middle - O(N)</span></div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno"> 167</span> <span class="keywordflow">if</span> (window.size() % 2 != 0) {</div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno"> 168</span> <span class="keywordflow">return</span> median;</div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno"> 169</span> }</div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno"> 170</span> <span class="keywordflow">return</span> 0.5f * median +</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno"> 171</span> 0.5f * *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/iterator/next.html">next</a>(window.begin(), window.size() / 2 - 1); <span class="comment">/// O(N)</span></div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno"> 172</span> }</div>
<div class="ttc" id="aclassprobability_1_1windowed__median_1_1_windowed_median_html_a825a7aaef844c9f743a27b268e8569b2"><div class="ttname"><a href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">probability::windowed_median::WindowedMedian::_window</a></div><div class="ttdeci">Window _window</div><div class="ttdoc">a sliding window of values along the stream</div><div class="ttdef"><b>Definition:</b> windowed_median.cpp:58</div></div>
<div class="ttc" id="asort_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/list/sort.html">std::list::sort</a></div><div class="ttdeci">T sort(T... args)</div></div>
</div><!-- fragment --><div class="dynheader">
@@ -370,19 +371,19 @@ Here is the call graph for this function:</div>
<p >If exceeding size of window, pop from its left side</p>
<p >Erase from the multi-value BST the window left side value</p>
<p >Pop the left side value from the window - O(1)</p>
<div class="fragment"><div class="line"><a id="l00128" name="l00128"></a><span class="lineno"> 128</span> {</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> <span class="comment"></span></div>
<div class="fragment"><div class="line"><a id="l00129" name="l00129"></a><span class="lineno"> 129</span> {<span class="comment"></span></div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno"> 130</span><span class="comment"> /// Push new value to the back of the sliding window - O(1)</span></div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno"> 131</span><span class="comment"></span> <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">_window</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/push_back.html">push_back</a>(value);</div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno"> 132</span> <a class="code hl_function" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a3a7f57679e9cd6c9f042dfd0612b2b24">insertToSorted</a>(value); <span class="comment">// Insert value to the multi-value BST - O(logN)</span></div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">_window</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/size.html">size</a>() &gt; <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aafda847b152684578dab891e5268d750">_windowSize</a>) { <span class="comment">/// If exceeding size of window, pop</span><span class="comment"></span></div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span><span class="comment"> /// from its left side</span></div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span><span class="comment"></span> <a class="code hl_function" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#af544e271ea19a6fd69a6b3ed6816453e">eraseFromSorted</a>(<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">_window</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/front.html">front</a>()); <span class="comment">/// Erase from the multi-value BST</span><span class="comment"></span></div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span><span class="comment"> /// the window left side value</span></div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span><span class="comment"></span> <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">_window</a></div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span> .<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/pop_front.html">pop_front</a>(); <span class="comment">/// Pop the left side value from the window - O(1)</span></div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span> }</div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span> }</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno"> 133</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">_window</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/size.html">size</a>() &gt; <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#aafda847b152684578dab891e5268d750">_windowSize</a>) { <span class="comment">/// If exceeding size of window,</span><span class="comment"></span></div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno"> 134</span><span class="comment"> /// pop from its left side</span></div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"> 135</span><span class="comment"></span> <a class="code hl_function" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#af544e271ea19a6fd69a6b3ed6816453e">eraseFromSorted</a>(</div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno"> 136</span> <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">_window</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/front.html">front</a>()); <span class="comment">/// Erase from the multi-value BST</span><span class="comment"></span></div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno"> 137</span><span class="comment"> /// the window left side value</span></div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno"> 138</span><span class="comment"></span> <a class="code hl_variable" href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a825a7aaef844c9f743a27b268e8569b2">_window</a>.<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/list/pop_front.html">pop_front</a>(); <span class="comment">/// Pop the left side value from the window -</span><span class="comment"></span></div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"> 139</span><span class="comment"> /// O(1)</span></div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno"> 140</span><span class="comment"></span> }</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"> 141</span> }</div>
<div class="ttc" id="aclassprobability_1_1windowed__median_1_1_windowed_median_html_a3a7f57679e9cd6c9f042dfd0612b2b24"><div class="ttname"><a href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#a3a7f57679e9cd6c9f042dfd0612b2b24">probability::windowed_median::WindowedMedian::insertToSorted</a></div><div class="ttdeci">void insertToSorted(int value)</div><div class="ttdoc">Inserts a value to a sorted multi-value BST.</div><div class="ttdef"><b>Definition:</b> windowed_median.cpp:69</div></div>
<div class="ttc" id="aclassprobability_1_1windowed__median_1_1_windowed_median_html_af544e271ea19a6fd69a6b3ed6816453e"><div class="ttname"><a href="../../df/d34/classprobability_1_1windowed__median_1_1_windowed_median.html#af544e271ea19a6fd69a6b3ed6816453e">probability::windowed_median::WindowedMedian::eraseFromSorted</a></div><div class="ttdeci">void eraseFromSorted(int value)</div><div class="ttdoc">Erases a value from a sorted multi-value BST.</div><div class="ttdef"><b>Definition:</b> windowed_median.cpp:95</div></div>
<div class="ttc" id="afront_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/list/front.html">std::list::front</a></div><div class="ttdeci">T front(T... args)</div></div>