349 lines
18 KiB
HTML
349 lines
18 KiB
HTML
<!doctype html>
|
||
<html class="default no-js">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||
<title>HashHelpers | @esengine/egret-framework</title>
|
||
<meta name="description" content="Documentation for @esengine/egret-framework">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<link rel="stylesheet" href="../assets/css/main.css">
|
||
</head>
|
||
<body>
|
||
<header>
|
||
<div class="tsd-page-toolbar">
|
||
<div class="container">
|
||
<div class="table-wrap">
|
||
<div class="table-cell" id="tsd-search" data-index="../assets/js/search.json" data-base="..">
|
||
<div class="field">
|
||
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
|
||
<input id="tsd-search-field" type="text" />
|
||
</div>
|
||
<ul class="results">
|
||
<li class="state loading">Preparing search index...</li>
|
||
<li class="state failure">The search index is not available</li>
|
||
</ul>
|
||
<a href="../index.html" class="title">@esengine/egret-framework</a>
|
||
</div>
|
||
<div class="table-cell" id="tsd-widgets">
|
||
<div id="tsd-filter">
|
||
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
|
||
<div class="tsd-filter-group">
|
||
<div class="tsd-select" id="tsd-filter-visibility">
|
||
<span class="tsd-select-label">All</span>
|
||
<ul class="tsd-select-list">
|
||
<li data-value="public">Public</li>
|
||
<li data-value="protected">Public/Protected</li>
|
||
<li data-value="private" class="selected">All</li>
|
||
</ul>
|
||
</div>
|
||
<input type="checkbox" id="tsd-filter-inherited" checked />
|
||
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
|
||
<input type="checkbox" id="tsd-filter-externals" checked />
|
||
<label class="tsd-widget" for="tsd-filter-externals">Externals</label>
|
||
<input type="checkbox" id="tsd-filter-only-exported" />
|
||
<label class="tsd-widget" for="tsd-filter-only-exported">Only exported</label>
|
||
</div>
|
||
</div>
|
||
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="tsd-page-title">
|
||
<div class="container">
|
||
<ul class="tsd-breadcrumb">
|
||
<li>
|
||
<a href="../globals.html">Globals</a>
|
||
</li>
|
||
<li>
|
||
<a href="../modules/_ecs_utils_hashhelper_.html">"ECS/Utils/HashHelper"</a>
|
||
</li>
|
||
<li>
|
||
<a href="../modules/_ecs_utils_hashhelper_.es.html">es</a>
|
||
</li>
|
||
<li>
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html">HashHelpers</a>
|
||
</li>
|
||
</ul>
|
||
<h1>Class HashHelpers</h1>
|
||
</div>
|
||
</div>
|
||
</header>
|
||
<div class="container container-main">
|
||
<div class="row">
|
||
<div class="col-8 col-content">
|
||
<section class="tsd-panel tsd-hierarchy">
|
||
<h3>Hierarchy</h3>
|
||
<ul class="tsd-hierarchy">
|
||
<li>
|
||
<span class="target">HashHelpers</span>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section class="tsd-panel-group tsd-index-group">
|
||
<h2>Index</h2>
|
||
<section class="tsd-panel tsd-index-panel">
|
||
<div class="tsd-index-content">
|
||
<section class="tsd-index-section ">
|
||
<h3>Properties</h3>
|
||
<ul class="tsd-index-list">
|
||
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="_ecs_utils_hashhelper_.es.hashhelpers.html#hashcollisionthreshold" class="tsd-kind-icon">hash<wbr>Collision<wbr>Threshold</a></li>
|
||
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="_ecs_utils_hashhelper_.es.hashhelpers.html#hashprime" class="tsd-kind-icon">hash<wbr>Prime</a></li>
|
||
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="_ecs_utils_hashhelper_.es.hashhelpers.html#maxprimearraylength" class="tsd-kind-icon">max<wbr>Prime<wbr>Array<wbr>Length</a></li>
|
||
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><a href="_ecs_utils_hashhelper_.es.hashhelpers.html#primes" class="tsd-kind-icon">primes</a></li>
|
||
</ul>
|
||
</section>
|
||
<section class="tsd-index-section ">
|
||
<h3>Methods</h3>
|
||
<ul class="tsd-index-list">
|
||
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="_ecs_utils_hashhelper_.es.hashhelpers.html#expandprime" class="tsd-kind-icon">expand<wbr>Prime</a></li>
|
||
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="_ecs_utils_hashhelper_.es.hashhelpers.html#gethashcode" class="tsd-kind-icon">get<wbr>Hash<wbr>Code</a></li>
|
||
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="_ecs_utils_hashhelper_.es.hashhelpers.html#getprime" class="tsd-kind-icon">get<wbr>Prime</a></li>
|
||
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><a href="_ecs_utils_hashhelper_.es.hashhelpers.html#isprime" class="tsd-kind-icon">is<wbr>Prime</a></li>
|
||
</ul>
|
||
</section>
|
||
</div>
|
||
</section>
|
||
</section>
|
||
<section class="tsd-panel-group tsd-member-group ">
|
||
<h2>Properties</h2>
|
||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-static">
|
||
<a name="hashcollisionthreshold" class="tsd-anchor"></a>
|
||
<h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> hash<wbr>Collision<wbr>Threshold</h3>
|
||
<div class="tsd-signature tsd-kind-icon">hash<wbr>Collision<wbr>Threshold<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> = 100</span></div>
|
||
<aside class="tsd-sources">
|
||
<ul>
|
||
<li>Defined in <a href="https://github.com/esengine/egret-framework/blob/562bacb/source/src/ECS/Utils/HashHelper.ts#L3">src/ECS/Utils/HashHelper.ts:3</a></li>
|
||
</ul>
|
||
</aside>
|
||
</section>
|
||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-static">
|
||
<a name="hashprime" class="tsd-anchor"></a>
|
||
<h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> hash<wbr>Prime</h3>
|
||
<div class="tsd-signature tsd-kind-icon">hash<wbr>Prime<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol"> = 101</span></div>
|
||
<aside class="tsd-sources">
|
||
<ul>
|
||
<li>Defined in <a href="https://github.com/esengine/egret-framework/blob/562bacb/source/src/ECS/Utils/HashHelper.ts#L4">src/ECS/Utils/HashHelper.ts:4</a></li>
|
||
</ul>
|
||
</aside>
|
||
</section>
|
||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-static">
|
||
<a name="maxprimearraylength" class="tsd-anchor"></a>
|
||
<h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> max<wbr>Prime<wbr>Array<wbr>Length</h3>
|
||
<div class="tsd-signature tsd-kind-icon">max<wbr>Prime<wbr>Array<wbr>Length<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">2146435069</span><span class="tsd-signature-symbol"> = 2146435069</span></div>
|
||
<aside class="tsd-sources">
|
||
<ul>
|
||
<li>Defined in <a href="https://github.com/esengine/egret-framework/blob/562bacb/source/src/ECS/Utils/HashHelper.ts#L23">src/ECS/Utils/HashHelper.ts:23</a></li>
|
||
</ul>
|
||
</aside>
|
||
<div class="tsd-comment tsd-typography">
|
||
<div class="lead">
|
||
<p>这是比Array.MaxArrayLength小的最大质数</p>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
<section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class tsd-is-static">
|
||
<a name="primes" class="tsd-anchor"></a>
|
||
<h3><span class="tsd-flag ts-flagStatic">Static</span> <span class="tsd-flag ts-flagReadonly">Readonly</span> primes</h3>
|
||
<div class="tsd-signature tsd-kind-icon">primes<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> = [3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919,1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591,17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437,187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263,1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369]</span></div>
|
||
<aside class="tsd-sources">
|
||
<ul>
|
||
<li>Defined in <a href="https://github.com/esengine/egret-framework/blob/562bacb/source/src/ECS/Utils/HashHelper.ts#L14">src/ECS/Utils/HashHelper.ts:14</a></li>
|
||
</ul>
|
||
</aside>
|
||
<div class="tsd-comment tsd-typography">
|
||
<div class="lead">
|
||
<p>用来作为哈希表大小的质数表。
|
||
一个典型的调整大小的算法会在这个数组中选取比之前容量大两倍的最小质数。
|
||
假设我们的Hashtable当前的容量为x,并且添加了足够多的元素,因此需要进行大小调整。
|
||
调整大小首先计算2x,然后在表中找到第一个大于2x的质数,即如果质数的顺序是p_1,p_2,...,p_i,...,则找到p_n,使p_n-1 < 2x < p_n。
|
||
双倍对于保持哈希特操作的渐近复杂度是很重要的,比如添加。
|
||
拥有一个质数可以保证双倍哈希不会导致无限循环。 IE,你的哈希函数将是h1(key)+i*h2(key),0 <= i < size.h2和size必须是相对质数。</p>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</section>
|
||
<section class="tsd-panel-group tsd-member-group ">
|
||
<h2>Methods</h2>
|
||
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<a name="expandprime" class="tsd-anchor"></a>
|
||
<h3><span class="tsd-flag ts-flagStatic">Static</span> expand<wbr>Prime</h3>
|
||
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<li class="tsd-signature tsd-kind-icon">expand<wbr>Prime<span class="tsd-signature-symbol">(</span>oldSize<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
|
||
</ul>
|
||
<ul class="tsd-descriptions">
|
||
<li class="tsd-description">
|
||
<aside class="tsd-sources">
|
||
<ul>
|
||
<li>Defined in <a href="https://github.com/esengine/egret-framework/blob/562bacb/source/src/ECS/Utils/HashHelper.ts#L59">src/ECS/Utils/HashHelper.ts:59</a></li>
|
||
</ul>
|
||
</aside>
|
||
<div class="tsd-comment tsd-typography">
|
||
</div>
|
||
<h4 class="tsd-parameters-title">Parameters</h4>
|
||
<ul class="tsd-parameters">
|
||
<li>
|
||
<h5>oldSize: <span class="tsd-signature-type">number</span></h5>
|
||
</li>
|
||
</ul>
|
||
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
|
||
<p>返回要增长的哈希特表的大小</p>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<a name="gethashcode" class="tsd-anchor"></a>
|
||
<h3><span class="tsd-flag ts-flagStatic">Static</span> get<wbr>Hash<wbr>Code</h3>
|
||
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<li class="tsd-signature tsd-kind-icon">get<wbr>Hash<wbr>Code<span class="tsd-signature-symbol">(</span>str<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
|
||
</ul>
|
||
<ul class="tsd-descriptions">
|
||
<li class="tsd-description">
|
||
<aside class="tsd-sources">
|
||
<ul>
|
||
<li>Defined in <a href="https://github.com/esengine/egret-framework/blob/562bacb/source/src/ECS/Utils/HashHelper.ts#L71">src/ECS/Utils/HashHelper.ts:71</a></li>
|
||
</ul>
|
||
</aside>
|
||
<h4 class="tsd-parameters-title">Parameters</h4>
|
||
<ul class="tsd-parameters">
|
||
<li>
|
||
<h5>str: <span class="tsd-signature-type">any</span></h5>
|
||
</li>
|
||
</ul>
|
||
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<a name="getprime" class="tsd-anchor"></a>
|
||
<h3><span class="tsd-flag ts-flagStatic">Static</span> get<wbr>Prime</h3>
|
||
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<li class="tsd-signature tsd-kind-icon">get<wbr>Prime<span class="tsd-signature-symbol">(</span>min<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></li>
|
||
</ul>
|
||
<ul class="tsd-descriptions">
|
||
<li class="tsd-description">
|
||
<aside class="tsd-sources">
|
||
<ul>
|
||
<li>Defined in <a href="https://github.com/esengine/egret-framework/blob/562bacb/source/src/ECS/Utils/HashHelper.ts#L37">src/ECS/Utils/HashHelper.ts:37</a></li>
|
||
</ul>
|
||
</aside>
|
||
<h4 class="tsd-parameters-title">Parameters</h4>
|
||
<ul class="tsd-parameters">
|
||
<li>
|
||
<h5>min: <span class="tsd-signature-type">number</span></h5>
|
||
</li>
|
||
</ul>
|
||
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">number</span></h4>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
<section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<a name="isprime" class="tsd-anchor"></a>
|
||
<h3><span class="tsd-flag ts-flagStatic">Static</span> is<wbr>Prime</h3>
|
||
<ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<li class="tsd-signature tsd-kind-icon">is<wbr>Prime<span class="tsd-signature-symbol">(</span>candidate<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></li>
|
||
</ul>
|
||
<ul class="tsd-descriptions">
|
||
<li class="tsd-description">
|
||
<aside class="tsd-sources">
|
||
<ul>
|
||
<li>Defined in <a href="https://github.com/esengine/egret-framework/blob/562bacb/source/src/ECS/Utils/HashHelper.ts#L25">src/ECS/Utils/HashHelper.ts:25</a></li>
|
||
</ul>
|
||
</aside>
|
||
<h4 class="tsd-parameters-title">Parameters</h4>
|
||
<ul class="tsd-parameters">
|
||
<li>
|
||
<h5>candidate: <span class="tsd-signature-type">number</span></h5>
|
||
</li>
|
||
</ul>
|
||
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
</section>
|
||
</div>
|
||
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
|
||
<nav class="tsd-navigation primary">
|
||
<ul>
|
||
<li class="globals ">
|
||
<a href="../globals.html"><em>Globals</em></a>
|
||
</li>
|
||
<li class="current tsd-kind-module">
|
||
<a href="../modules/_ecs_utils_hashhelper_.html">"ECS/<wbr>Utils/<wbr>Hash<wbr>Helper"</a>
|
||
<ul>
|
||
<li class="current tsd-kind-namespace tsd-parent-kind-module">
|
||
<a href="../modules/_ecs_utils_hashhelper_.es.html">es</a>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</nav>
|
||
<nav class="tsd-navigation secondary menu-sticky">
|
||
<ul class="before-current">
|
||
</ul>
|
||
<ul class="current">
|
||
<li class="current tsd-kind-class tsd-parent-kind-namespace">
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html" class="tsd-kind-icon">Hash<wbr>Helpers</a>
|
||
<ul>
|
||
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html#hashcollisionthreshold" class="tsd-kind-icon">hash<wbr>Collision<wbr>Threshold</a>
|
||
</li>
|
||
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html#hashprime" class="tsd-kind-icon">hash<wbr>Prime</a>
|
||
</li>
|
||
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html#maxprimearraylength" class="tsd-kind-icon">max<wbr>Prime<wbr>Array<wbr>Length</a>
|
||
</li>
|
||
<li class=" tsd-kind-property tsd-parent-kind-class tsd-is-static">
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html#primes" class="tsd-kind-icon">primes</a>
|
||
</li>
|
||
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html#expandprime" class="tsd-kind-icon">expand<wbr>Prime</a>
|
||
</li>
|
||
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html#gethashcode" class="tsd-kind-icon">get<wbr>Hash<wbr>Code</a>
|
||
</li>
|
||
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html#getprime" class="tsd-kind-icon">get<wbr>Prime</a>
|
||
</li>
|
||
<li class=" tsd-kind-method tsd-parent-kind-class tsd-is-static">
|
||
<a href="_ecs_utils_hashhelper_.es.hashhelpers.html#isprime" class="tsd-kind-icon">is<wbr>Prime</a>
|
||
</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<ul class="after-current">
|
||
</ul>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<footer class="with-border-bottom">
|
||
<div class="container">
|
||
<h2>Legend</h2>
|
||
<div class="tsd-legend-group">
|
||
<ul class="tsd-legend">
|
||
<li class="tsd-kind-namespace"><span class="tsd-kind-icon">Namespace</span></li>
|
||
<li class="tsd-kind-variable"><span class="tsd-kind-icon">Variable</span></li>
|
||
</ul>
|
||
<ul class="tsd-legend">
|
||
<li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li>
|
||
<li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li>
|
||
</ul>
|
||
<ul class="tsd-legend">
|
||
<li class="tsd-kind-interface tsd-has-type-parameter"><span class="tsd-kind-icon">Interface with type parameter</span></li>
|
||
</ul>
|
||
<ul class="tsd-legend">
|
||
<li class="tsd-kind-class"><span class="tsd-kind-icon">Class</span></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
<div class="container tsd-generator">
|
||
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
|
||
</div>
|
||
<div class="overlay"></div>
|
||
<script src="../assets/js/main.js"></script>
|
||
<script>if (location.protocol == 'file:') document.write('<script src="../assets/js/search.js"><' + '/script>');</script>
|
||
</body>
|
||
</html> |