mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
deploy: 020b285808
This commit is contained in:
250
DecayingSample_8h_source.html
Normal file
250
DecayingSample_8h_source.html
Normal file
@@ -0,0 +1,250 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.17"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>rippled: DecayingSample.h Source File</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<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>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">rippled
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.17 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||||
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript" src="menudata.js"></script>
|
||||
<script type="text/javascript" src="menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
||||
$(function() {
|
||||
initMenu('',true,false,'search.php','Search');
|
||||
$(document).ready(function() { init_search(); });
|
||||
});
|
||||
/* @license-end */</script>
|
||||
<div id="main-nav"></div>
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
onmouseover="return searchBox.OnSearchSelectShow()"
|
||||
onmouseout="return searchBox.OnSearchSelectHide()"
|
||||
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||||
</div>
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<iframe src="javascript:void(0)" frameborder="0"
|
||||
name="MSearchResults" id="MSearchResults">
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
<div id="nav-path" class="navpath">
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="dir_df9c78dcf3f59a33b12284f95992a64b.html">ripple</a></li><li class="navelem"><a class="el" href="dir_5f536ab1985a8dcd28bcfd618bc58e92.html">basics</a></li> </ul>
|
||||
</div>
|
||||
</div><!-- top -->
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">DecayingSample.h</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">//------------------------------------------------------------------------------</span></div>
|
||||
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment">/*</span></div>
|
||||
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> This file is part of rippled: https://github.com/ripple/rippled</span></div>
|
||||
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> Copyright (c) 2012, 2013 Ripple Labs Inc.</span></div>
|
||||
<div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"></span> </div>
|
||||
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> Permission to use, copy, modify, and/or distribute this software for any</span></div>
|
||||
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> purpose with or without fee is hereby granted, provided that the above</span></div>
|
||||
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> copyright notice and this permission notice appear in all copies.</span></div>
|
||||
<div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"></span> </div>
|
||||
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span></div>
|
||||
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span></div>
|
||||
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR</span></div>
|
||||
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span></div>
|
||||
<div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN</span></div>
|
||||
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF</span></div>
|
||||
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span></div>
|
||||
<div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment">*/</span></div>
|
||||
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment">//==============================================================================</span></div>
|
||||
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>  </div>
|
||||
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#ifndef RIPPLE_BASICS_DECAYINGSAMPLE_H_INCLUDED</span></div>
|
||||
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#define RIPPLE_BASICS_DECAYINGSAMPLE_H_INCLUDED</span></div>
|
||||
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span>  </div>
|
||||
<div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor">#include <<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/chrono.html">chrono</a>></span></div>
|
||||
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#include <<a class="codeRef" href="http://en.cppreference.com/w/cpp/header/cmath.html">cmath</a>></span></div>
|
||||
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  </div>
|
||||
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="keyword">namespace </span><a class="code" href="namespaceripple.html">ripple</a> {</div>
|
||||
<div class="line"><a name="l00027"></a><span class="lineno"> 27</span>  </div>
|
||||
<div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="keyword">template</span> <<span class="keywordtype">int</span> Window, <span class="keyword">typename</span> Clock></div>
|
||||
<div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="classripple_1_1DecayingSample.html"> 32</a></span> <span class="keyword">class </span><a class="code" href="classripple_1_1DecayingSample.html">DecayingSample</a></div>
|
||||
<div class="line"><a name="l00033"></a><span class="lineno"> 33</span> {</div>
|
||||
<div class="line"><a name="l00034"></a><span class="lineno"> 34</span> <span class="keyword">public</span>:</div>
|
||||
<div class="line"><a name="l00035"></a><span class="lineno"><a class="line" href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635"> 35</a></span>  <span class="keyword">using</span> <a class="code" href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635">value_type</a> = <span class="keyword">typename</span> Clock::duration::rep;</div>
|
||||
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="classripple_1_1DecayingSample.html#a901436f0dac882f0d1b53d99bbd77937"> 36</a></span>  <span class="keyword">using</span> <a class="code" href="classripple_1_1DecayingSample.html#a901436f0dac882f0d1b53d99bbd77937">time_point</a> = <span class="keyword">typename</span> Clock::time_point;</div>
|
||||
<div class="line"><a name="l00037"></a><span class="lineno"> 37</span>  </div>
|
||||
<div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  <a class="code" href="classripple_1_1DecayingSample.html#abe1d19ee0af1f06ec16bbcb9d72d83fc">DecayingSample</a> () = <span class="keyword">delete</span>;</div>
|
||||
<div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  </div>
|
||||
<div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="classripple_1_1DecayingSample.html#a2f7df15dc3181f3043527b4aff1cad7d"> 43</a></span>  <span class="keyword">explicit</span> <a class="code" href="classripple_1_1DecayingSample.html#a2f7df15dc3181f3043527b4aff1cad7d">DecayingSample</a> (<a class="code" href="classripple_1_1DecayingSample.html#a901436f0dac882f0d1b53d99bbd77937">time_point</a> now)</div>
|
||||
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  : <a class="code" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">m_value</a> (<a class="code" href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635">value_type</a>())</div>
|
||||
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  , <a class="code" href="classripple_1_1DecayingSample.html#a6b925abb3876f5e45392bcc96e8511cf">m_when</a> (now)</div>
|
||||
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  {</div>
|
||||
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  }</div>
|
||||
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  </div>
|
||||
<div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="classripple_1_1DecayingSample.html#a50fc616b35ac6589ed3af61baf9e1dec"> 52</a></span>  <a class="code" href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635">value_type</a> <a class="code" href="classripple_1_1DecayingSample.html#a50fc616b35ac6589ed3af61baf9e1dec">add</a> (<a class="code" href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635">value_type</a> <a class="code" href="classripple_1_1DecayingSample.html#aa592c9a4ac598241e496d8962caaf6f0">value</a>, <a class="code" href="classripple_1_1DecayingSample.html#a901436f0dac882f0d1b53d99bbd77937">time_point</a> now)</div>
|
||||
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  {</div>
|
||||
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <a class="code" href="classripple_1_1DecayingSample.html#a272fa376fd4d4a876d2ff2f6fdca4ec7">decay</a> (now);</div>
|
||||
<div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <a class="code" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">m_value</a> += <a class="code" href="classripple_1_1DecayingSample.html#aa592c9a4ac598241e496d8962caaf6f0">value</a>;</div>
|
||||
<div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  <span class="keywordflow">return</span> <a class="code" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">m_value</a> / Window;</div>
|
||||
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  }</div>
|
||||
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  </div>
|
||||
<div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="classripple_1_1DecayingSample.html#aa592c9a4ac598241e496d8962caaf6f0"> 62</a></span>  <a class="code" href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635">value_type</a> <a class="code" href="classripple_1_1DecayingSample.html#aa592c9a4ac598241e496d8962caaf6f0">value</a> (<a class="code" href="classripple_1_1DecayingSample.html#a901436f0dac882f0d1b53d99bbd77937">time_point</a> now)</div>
|
||||
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  {</div>
|
||||
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  <a class="code" href="classripple_1_1DecayingSample.html#a272fa376fd4d4a876d2ff2f6fdca4ec7">decay</a> (now);</div>
|
||||
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  <span class="keywordflow">return</span> <a class="code" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">m_value</a> / Window;</div>
|
||||
<div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  }</div>
|
||||
<div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  </div>
|
||||
<div class="line"><a name="l00068"></a><span class="lineno"> 68</span> <span class="keyword">private</span>:</div>
|
||||
<div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  <span class="comment">// Apply exponential decay based on the specified time.</span></div>
|
||||
<div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="classripple_1_1DecayingSample.html#a272fa376fd4d4a876d2ff2f6fdca4ec7"> 70</a></span>  <span class="keywordtype">void</span> <a class="code" href="classripple_1_1DecayingSample.html#a272fa376fd4d4a876d2ff2f6fdca4ec7">decay</a> (<a class="code" href="classripple_1_1DecayingSample.html#a901436f0dac882f0d1b53d99bbd77937">time_point</a> now)</div>
|
||||
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  {</div>
|
||||
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  <span class="keywordflow">if</span> (now == <a class="code" href="classripple_1_1DecayingSample.html#a6b925abb3876f5e45392bcc96e8511cf">m_when</a>)</div>
|
||||
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  <span class="keywordflow">return</span>;</div>
|
||||
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  </div>
|
||||
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <span class="keywordflow">if</span> (<a class="code" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">m_value</a> != <a class="code" href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635">value_type</a>())</div>
|
||||
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  {</div>
|
||||
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  <a class="codeRef" href="http://en.cppreference.com/w/cpp/types/size_t.html">std::size_t</a> elapsed = <a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration/duration_cast.html">std::chrono::duration_cast</a><</div>
|
||||
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  <a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a>>(now - <a class="code" href="classripple_1_1DecayingSample.html#a6b925abb3876f5e45392bcc96e8511cf">m_when</a>).count();</div>
|
||||
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  </div>
|
||||
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  <span class="comment">// A span larger than four times the window decays the</span></div>
|
||||
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  <span class="comment">// value to an insignificant amount so just reset it.</span></div>
|
||||
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  <span class="comment">//</span></div>
|
||||
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  <span class="keywordflow">if</span> (elapsed > 4 * Window)</div>
|
||||
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  {</div>
|
||||
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <a class="code" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">m_value</a> = <a class="code" href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635">value_type</a>();</div>
|
||||
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  }</div>
|
||||
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  <span class="keywordflow">else</span></div>
|
||||
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  {</div>
|
||||
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  <span class="keywordflow">while</span> (elapsed--)</div>
|
||||
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  <a class="code" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">m_value</a> -= (<a class="code" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">m_value</a> + Window - 1) / Window;</div>
|
||||
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  }</div>
|
||||
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  }</div>
|
||||
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  </div>
|
||||
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  <a class="code" href="classripple_1_1DecayingSample.html#a6b925abb3876f5e45392bcc96e8511cf">m_when</a> = now;</div>
|
||||
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  }</div>
|
||||
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  </div>
|
||||
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  <span class="comment">// Current value in exponential units</span></div>
|
||||
<div class="line"><a name="l00098"></a><span class="lineno"><a class="line" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a"> 98</a></span>  <a class="code" href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635">value_type</a> <a class="code" href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">m_value</a>;</div>
|
||||
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  </div>
|
||||
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  <span class="comment">// Last time the aging function was applied</span></div>
|
||||
<div class="line"><a name="l00101"></a><span class="lineno"><a class="line" href="classripple_1_1DecayingSample.html#a6b925abb3876f5e45392bcc96e8511cf"> 101</a></span>  <a class="code" href="classripple_1_1DecayingSample.html#a901436f0dac882f0d1b53d99bbd77937">time_point</a> <a class="code" href="classripple_1_1DecayingSample.html#a6b925abb3876f5e45392bcc96e8511cf">m_when</a>;</div>
|
||||
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span> };</div>
|
||||
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  </div>
|
||||
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span> <span class="comment">//------------------------------------------------------------------------------</span></div>
|
||||
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  </div>
|
||||
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span> <span class="keyword">template</span> <<span class="keywordtype">int</span> HalfLife, <span class="keyword">class</span> Clock></div>
|
||||
<div class="line"><a name="l00110"></a><span class="lineno"><a class="line" href="classripple_1_1DecayWindow.html"> 110</a></span> <span class="keyword">class </span><a class="code" href="classripple_1_1DecayWindow.html">DecayWindow</a></div>
|
||||
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span> {</div>
|
||||
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span> <span class="keyword">public</span>:</div>
|
||||
<div class="line"><a name="l00113"></a><span class="lineno"><a class="line" href="classripple_1_1DecayWindow.html#aa3f16841f2b81e3bbcc19f5496e64fe7"> 113</a></span>  <span class="keyword">using</span> <a class="code" href="classripple_1_1DecayWindow.html#aa3f16841f2b81e3bbcc19f5496e64fe7">time_point</a> = <span class="keyword">typename</span> Clock::time_point;</div>
|
||||
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  </div>
|
||||
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  <span class="keyword">explicit</span></div>
|
||||
<div class="line"><a name="l00116"></a><span class="lineno"><a class="line" href="classripple_1_1DecayWindow.html#a8771bf6d66c80e687027fd1e0e3dd72a"> 116</a></span>  <a class="code" href="classripple_1_1DecayWindow.html#a8771bf6d66c80e687027fd1e0e3dd72a">DecayWindow</a> (<a class="code" href="classripple_1_1DecayWindow.html#aa3f16841f2b81e3bbcc19f5496e64fe7">time_point</a> now)</div>
|
||||
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  : <a class="code" href="classripple_1_1DecayWindow.html#a98e9e4239959749b5bc8f4cf8a3aa124">value_</a>(0)</div>
|
||||
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  , <a class="code" href="classripple_1_1DecayWindow.html#a753b4185a2902da00f2f3ebf46efe512">when_</a>(now)</div>
|
||||
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  {</div>
|
||||
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  }</div>
|
||||
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  </div>
|
||||
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  <span class="keywordtype">void</span></div>
|
||||
<div class="line"><a name="l00123"></a><span class="lineno"><a class="line" href="classripple_1_1DecayWindow.html#ad3cd95404ae6e74760983eac7cdedd26"> 123</a></span>  <a class="code" href="classripple_1_1DecayWindow.html#ad3cd95404ae6e74760983eac7cdedd26">add</a> (<span class="keywordtype">double</span> <a class="code" href="classripple_1_1DecayWindow.html#a85439c48487ee30c2aa2bafce7dc795b">value</a>, <a class="code" href="classripple_1_1DecayWindow.html#aa3f16841f2b81e3bbcc19f5496e64fe7">time_point</a> now)</div>
|
||||
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  {</div>
|
||||
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  <a class="code" href="classripple_1_1DecayWindow.html#a3c1e28310577d634672418a8454e9315">decay</a>(now);</div>
|
||||
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <a class="code" href="classripple_1_1DecayWindow.html#a98e9e4239959749b5bc8f4cf8a3aa124">value_</a> += <a class="code" href="classripple_1_1DecayWindow.html#a85439c48487ee30c2aa2bafce7dc795b">value</a>;</div>
|
||||
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  }</div>
|
||||
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  </div>
|
||||
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="keywordtype">double</span></div>
|
||||
<div class="line"><a name="l00130"></a><span class="lineno"><a class="line" href="classripple_1_1DecayWindow.html#a85439c48487ee30c2aa2bafce7dc795b"> 130</a></span>  <a class="code" href="classripple_1_1DecayWindow.html#a85439c48487ee30c2aa2bafce7dc795b">value</a> (<a class="code" href="classripple_1_1DecayWindow.html#aa3f16841f2b81e3bbcc19f5496e64fe7">time_point</a> now)</div>
|
||||
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  {</div>
|
||||
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  <a class="code" href="classripple_1_1DecayWindow.html#a3c1e28310577d634672418a8454e9315">decay</a>(now);</div>
|
||||
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="keywordflow">return</span> <a class="code" href="classripple_1_1DecayWindow.html#a98e9e4239959749b5bc8f4cf8a3aa124">value_</a> / HalfLife;</div>
|
||||
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  }</div>
|
||||
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  </div>
|
||||
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span> <span class="keyword">private</span>:</div>
|
||||
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  static_assert(HalfLife > 0,</div>
|
||||
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="stringliteral">"half life must be positive"</span>);</div>
|
||||
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  </div>
|
||||
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  <span class="keywordtype">void</span></div>
|
||||
<div class="line"><a name="l00141"></a><span class="lineno"><a class="line" href="classripple_1_1DecayWindow.html#a3c1e28310577d634672418a8454e9315"> 141</a></span>  <a class="code" href="classripple_1_1DecayWindow.html#a3c1e28310577d634672418a8454e9315">decay</a> (<a class="code" href="classripple_1_1DecayWindow.html#aa3f16841f2b81e3bbcc19f5496e64fe7">time_point</a> now)</div>
|
||||
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  {</div>
|
||||
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  <span class="keywordflow">if</span> (now <= <a class="code" href="classripple_1_1DecayWindow.html#a753b4185a2902da00f2f3ebf46efe512">when_</a>)</div>
|
||||
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  <span class="keywordflow">return</span>;</div>
|
||||
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  <span class="keyword">using namespace </span><a class="codeRef" href="http://en.cppreference.com/w/namespacestd_1_1chrono.html">std::chrono</a>;</div>
|
||||
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <span class="keyword">auto</span> <span class="keyword">const</span> elapsed =</div>
|
||||
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration.html">duration<double></a>(now - <a class="code" href="classripple_1_1DecayWindow.html#a753b4185a2902da00f2f3ebf46efe512">when_</a>).<a class="codeRef" href="http://en.cppreference.com/w/cpp/chrono/duration/count.html">count</a>();</div>
|
||||
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <a class="code" href="classripple_1_1DecayWindow.html#a98e9e4239959749b5bc8f4cf8a3aa124">value_</a> *= <a class="codeRef" href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a>(2.0, - elapsed / HalfLife);</div>
|
||||
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <a class="code" href="classripple_1_1DecayWindow.html#a753b4185a2902da00f2f3ebf46efe512">when_</a> = now;</div>
|
||||
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  }</div>
|
||||
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  </div>
|
||||
<div class="line"><a name="l00152"></a><span class="lineno"><a class="line" href="classripple_1_1DecayWindow.html#a98e9e4239959749b5bc8f4cf8a3aa124"> 152</a></span>  <span class="keywordtype">double</span> <a class="code" href="classripple_1_1DecayWindow.html#a98e9e4239959749b5bc8f4cf8a3aa124">value_</a>;</div>
|
||||
<div class="line"><a name="l00153"></a><span class="lineno"><a class="line" href="classripple_1_1DecayWindow.html#a753b4185a2902da00f2f3ebf46efe512"> 153</a></span>  <a class="code" href="classripple_1_1DecayWindow.html#aa3f16841f2b81e3bbcc19f5496e64fe7">time_point</a> <a class="code" href="classripple_1_1DecayWindow.html#a753b4185a2902da00f2f3ebf46efe512">when_</a>;</div>
|
||||
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span> };</div>
|
||||
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  </div>
|
||||
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span> }</div>
|
||||
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  </div>
|
||||
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span> <span class="preprocessor">#endif</span></div>
|
||||
</div><!-- fragment --></div><!-- contents -->
|
||||
<div class="ttc" id="aclassripple_1_1DecayWindow_html_a3c1e28310577d634672418a8454e9315"><div class="ttname"><a href="classripple_1_1DecayWindow.html#a3c1e28310577d634672418a8454e9315">ripple::DecayWindow::decay</a></div><div class="ttdeci">void decay(time_point now)</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00141">DecayingSample.h:141</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html_a0ae9c6057c3e868399f8cc1d07bca635"><div class="ttname"><a href="classripple_1_1DecayingSample.html#a0ae9c6057c3e868399f8cc1d07bca635">ripple::DecayingSample< decayWindowSeconds, abstract_clock< std::chrono::steady_clock > >::value_type</a></div><div class="ttdeci">typename abstract_clock< std::chrono::steady_clock > ::duration::rep value_type</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00035">DecayingSample.h:35</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html_ab9d9cd155bd1388fdb683ba35e1cec2a"><div class="ttname"><a href="classripple_1_1DecayingSample.html#ab9d9cd155bd1388fdb683ba35e1cec2a">ripple::DecayingSample::m_value</a></div><div class="ttdeci">value_type m_value</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00098">DecayingSample.h:98</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html_aa592c9a4ac598241e496d8962caaf6f0"><div class="ttname"><a href="classripple_1_1DecayingSample.html#aa592c9a4ac598241e496d8962caaf6f0">ripple::DecayingSample::value</a></div><div class="ttdeci">value_type value(time_point now)</div><div class="ttdoc">Retrieve the current value in normalized units.</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00062">DecayingSample.h:62</a></div></div>
|
||||
<div class="ttc" id="aduration_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/duration.html">std::chrono::seconds</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayWindow_html"><div class="ttname"><a href="classripple_1_1DecayWindow.html">ripple::DecayWindow</a></div><div class="ttdoc">Sampling function using exponential decay to provide a continuous value.</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00110">DecayingSample.h:110</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html_a6b925abb3876f5e45392bcc96e8511cf"><div class="ttname"><a href="classripple_1_1DecayingSample.html#a6b925abb3876f5e45392bcc96e8511cf">ripple::DecayingSample::m_when</a></div><div class="ttdeci">time_point m_when</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00101">DecayingSample.h:101</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html_a901436f0dac882f0d1b53d99bbd77937"><div class="ttname"><a href="classripple_1_1DecayingSample.html#a901436f0dac882f0d1b53d99bbd77937">ripple::DecayingSample< decayWindowSeconds, abstract_clock< std::chrono::steady_clock > >::time_point</a></div><div class="ttdeci">typename abstract_clock< std::chrono::steady_clock > ::time_point time_point</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00036">DecayingSample.h:36</a></div></div>
|
||||
<div class="ttc" id="acmath_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/cmath.html">cmath</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html_a2f7df15dc3181f3043527b4aff1cad7d"><div class="ttname"><a href="classripple_1_1DecayingSample.html#a2f7df15dc3181f3043527b4aff1cad7d">ripple::DecayingSample::DecayingSample</a></div><div class="ttdeci">DecayingSample(time_point now)</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00043">DecayingSample.h:43</a></div></div>
|
||||
<div class="ttc" id="achrono_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/header/chrono.html">chrono</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayWindow_html_aa3f16841f2b81e3bbcc19f5496e64fe7"><div class="ttname"><a href="classripple_1_1DecayWindow.html#aa3f16841f2b81e3bbcc19f5496e64fe7">ripple::DecayWindow::time_point</a></div><div class="ttdeci">typename Clock::time_point time_point</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00113">DecayingSample.h:113</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html_a50fc616b35ac6589ed3af61baf9e1dec"><div class="ttname"><a href="classripple_1_1DecayingSample.html#a50fc616b35ac6589ed3af61baf9e1dec">ripple::DecayingSample::add</a></div><div class="ttdeci">value_type add(value_type value, time_point now)</div><div class="ttdoc">Add a new sample.</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00052">DecayingSample.h:52</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayWindow_html_a8771bf6d66c80e687027fd1e0e3dd72a"><div class="ttname"><a href="classripple_1_1DecayWindow.html#a8771bf6d66c80e687027fd1e0e3dd72a">ripple::DecayWindow::DecayWindow</a></div><div class="ttdeci">DecayWindow(time_point now)</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00116">DecayingSample.h:116</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html_abe1d19ee0af1f06ec16bbcb9d72d83fc"><div class="ttname"><a href="classripple_1_1DecayingSample.html#abe1d19ee0af1f06ec16bbcb9d72d83fc">ripple::DecayingSample::DecayingSample</a></div><div class="ttdeci">DecayingSample()=delete</div></div>
|
||||
<div class="ttc" id="anamespaceripple_html"><div class="ttname"><a href="namespaceripple.html">ripple</a></div><div class="ttdoc">Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.</div><div class="ttdef"><b>Definition:</b> <a href="RCLCensorshipDetector_8h_source.html#l00029">RCLCensorshipDetector.h:29</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayWindow_html_a85439c48487ee30c2aa2bafce7dc795b"><div class="ttname"><a href="classripple_1_1DecayWindow.html#a85439c48487ee30c2aa2bafce7dc795b">ripple::DecayWindow::value</a></div><div class="ttdeci">double value(time_point now)</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00130">DecayingSample.h:130</a></div></div>
|
||||
<div class="ttc" id="aduration_cast_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/duration/duration_cast.html">std::chrono::duration_cast</a></div><div class="ttdeci">T duration_cast(T... args)</div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayWindow_html_a98e9e4239959749b5bc8f4cf8a3aa124"><div class="ttname"><a href="classripple_1_1DecayWindow.html#a98e9e4239959749b5bc8f4cf8a3aa124">ripple::DecayWindow::value_</a></div><div class="ttdeci">double value_</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00152">DecayingSample.h:152</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayWindow_html_ad3cd95404ae6e74760983eac7cdedd26"><div class="ttname"><a href="classripple_1_1DecayWindow.html#ad3cd95404ae6e74760983eac7cdedd26">ripple::DecayWindow::add</a></div><div class="ttdeci">void add(double value, time_point now)</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00123">DecayingSample.h:123</a></div></div>
|
||||
<div class="ttc" id="acount_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/chrono/duration/count.html">std::chrono::duration::count</a></div><div class="ttdeci">T count(T... args)</div></div>
|
||||
<div class="ttc" id="asize_t_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/types/size_t.html">std::size_t</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html"><div class="ttname"><a href="classripple_1_1DecayingSample.html">ripple::DecayingSample</a></div><div class="ttdoc">Sampling function using exponential decay to provide a continuous value.</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00032">DecayingSample.h:32</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayWindow_html_a753b4185a2902da00f2f3ebf46efe512"><div class="ttname"><a href="classripple_1_1DecayWindow.html#a753b4185a2902da00f2f3ebf46efe512">ripple::DecayWindow::when_</a></div><div class="ttdeci">time_point when_</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00153">DecayingSample.h:153</a></div></div>
|
||||
<div class="ttc" id="aclassripple_1_1DecayingSample_html_a272fa376fd4d4a876d2ff2f6fdca4ec7"><div class="ttname"><a href="classripple_1_1DecayingSample.html#a272fa376fd4d4a876d2ff2f6fdca4ec7">ripple::DecayingSample::decay</a></div><div class="ttdeci">void decay(time_point now)</div><div class="ttdef"><b>Definition:</b> <a href="DecayingSample_8h_source.html#l00070">DecayingSample.h:70</a></div></div>
|
||||
<div class="ttc" id="apow_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/numeric/math/pow.html">std::pow</a></div><div class="ttdeci">T pow(T... args)</div></div>
|
||||
<div class="ttc" id="anamespacestd_1_1chrono_html"><div class="ttname"><a href="http://en.cppreference.com/w/namespacestd_1_1chrono.html">std::chrono</a></div></div>
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
||||
</a> 1.8.17
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user