mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-27 16:56:30 +08:00
deploy
This commit is contained in:
parent
1eb6b6fe07
commit
1e290491ca
3 changed files with 11 additions and 11 deletions
|
@ -2134,7 +2134,7 @@ f(x) = x \% 100
|
||||||
<a id="__codelineno-20-12" name="__codelineno-20-12" href="#__codelineno-20-12"></a><span class="kd">class</span> <span class="nc">ArrayHashMap</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-20-12" name="__codelineno-20-12" href="#__codelineno-20-12"></a><span class="kd">class</span> <span class="nc">ArrayHashMap</span><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-20-13" name="__codelineno-20-13" href="#__codelineno-20-13"></a><span class="w"> </span><span class="kd">private</span><span class="w"> </span><span class="n">List</span><span class="o"><</span><span class="n">Entry</span><span class="o">></span><span class="w"> </span><span class="n">buckets</span><span class="p">;</span>
|
<a id="__codelineno-20-13" name="__codelineno-20-13" href="#__codelineno-20-13"></a><span class="w"> </span><span class="kd">private</span><span class="w"> </span><span class="n">List</span><span class="o"><</span><span class="n">Entry</span><span class="o">></span><span class="w"> </span><span class="n">buckets</span><span class="p">;</span>
|
||||||
<a id="__codelineno-20-14" name="__codelineno-20-14" href="#__codelineno-20-14"></a><span class="w"> </span><span class="kd">public</span><span class="w"> </span><span class="nf">ArrayHashMap</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-20-14" name="__codelineno-20-14" href="#__codelineno-20-14"></a><span class="w"> </span><span class="kd">public</span><span class="w"> </span><span class="nf">ArrayHashMap</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-20-15" name="__codelineno-20-15" href="#__codelineno-20-15"></a><span class="w"> </span><span class="c1">// 初始化一个长度为 100 的桶(数组)</span>
|
<a id="__codelineno-20-15" name="__codelineno-20-15" href="#__codelineno-20-15"></a><span class="w"> </span><span class="c1">// 初始化数组,包含 100 个桶</span>
|
||||||
<a id="__codelineno-20-16" name="__codelineno-20-16" href="#__codelineno-20-16"></a><span class="w"> </span><span class="n">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">ArrayList</span><span class="o"><></span><span class="p">();</span>
|
<a id="__codelineno-20-16" name="__codelineno-20-16" href="#__codelineno-20-16"></a><span class="w"> </span><span class="n">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="n">ArrayList</span><span class="o"><></span><span class="p">();</span>
|
||||||
<a id="__codelineno-20-17" name="__codelineno-20-17" href="#__codelineno-20-17"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="mi">100</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-20-17" name="__codelineno-20-17" href="#__codelineno-20-17"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="mi">100</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-20-18" name="__codelineno-20-18" href="#__codelineno-20-18"></a><span class="w"> </span><span class="n">buckets</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
|
<a id="__codelineno-20-18" name="__codelineno-20-18" href="#__codelineno-20-18"></a><span class="w"> </span><span class="n">buckets</span><span class="p">.</span><span class="na">add</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
|
||||||
|
@ -2226,8 +2226,8 @@ f(x) = x \% 100
|
||||||
<a id="__codelineno-21-15" name="__codelineno-21-15" href="#__codelineno-21-15"></a><span class="w"> </span><span class="n">vector</span><span class="o"><</span><span class="n">Entry</span><span class="o">*></span><span class="w"> </span><span class="n">buckets</span><span class="p">;</span>
|
<a id="__codelineno-21-15" name="__codelineno-21-15" href="#__codelineno-21-15"></a><span class="w"> </span><span class="n">vector</span><span class="o"><</span><span class="n">Entry</span><span class="o">*></span><span class="w"> </span><span class="n">buckets</span><span class="p">;</span>
|
||||||
<a id="__codelineno-21-16" name="__codelineno-21-16" href="#__codelineno-21-16"></a><span class="k">public</span><span class="o">:</span>
|
<a id="__codelineno-21-16" name="__codelineno-21-16" href="#__codelineno-21-16"></a><span class="k">public</span><span class="o">:</span>
|
||||||
<a id="__codelineno-21-17" name="__codelineno-21-17" href="#__codelineno-21-17"></a><span class="w"> </span><span class="n">ArrayHashMap</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-21-17" name="__codelineno-21-17" href="#__codelineno-21-17"></a><span class="w"> </span><span class="n">ArrayHashMap</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-21-18" name="__codelineno-21-18" href="#__codelineno-21-18"></a><span class="w"> </span><span class="c1">// 初始化一个长度为 100 的桶(数组)</span>
|
<a id="__codelineno-21-18" name="__codelineno-21-18" href="#__codelineno-21-18"></a><span class="w"> </span><span class="c1">// 初始化数组,包含 100 个桶</span>
|
||||||
<a id="__codelineno-21-19" name="__codelineno-21-19" href="#__codelineno-21-19"></a><span class="w"> </span><span class="n">buckets</span><span class="o">=</span><span class="w"> </span><span class="n">vector</span><span class="o"><</span><span class="n">Entry</span><span class="o">*></span><span class="p">(</span><span class="mi">100</span><span class="p">);</span>
|
<a id="__codelineno-21-19" name="__codelineno-21-19" href="#__codelineno-21-19"></a><span class="w"> </span><span class="n">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">vector</span><span class="o"><</span><span class="n">Entry</span><span class="o">*></span><span class="p">(</span><span class="mi">100</span><span class="p">);</span>
|
||||||
<a id="__codelineno-21-20" name="__codelineno-21-20" href="#__codelineno-21-20"></a><span class="w"> </span><span class="p">}</span>
|
<a id="__codelineno-21-20" name="__codelineno-21-20" href="#__codelineno-21-20"></a><span class="w"> </span><span class="p">}</span>
|
||||||
<a id="__codelineno-21-21" name="__codelineno-21-21" href="#__codelineno-21-21"></a>
|
<a id="__codelineno-21-21" name="__codelineno-21-21" href="#__codelineno-21-21"></a>
|
||||||
<a id="__codelineno-21-22" name="__codelineno-21-22" href="#__codelineno-21-22"></a><span class="w"> </span><span class="cm">/* 哈希函数 */</span>
|
<a id="__codelineno-21-22" name="__codelineno-21-22" href="#__codelineno-21-22"></a><span class="w"> </span><span class="cm">/* 哈希函数 */</span>
|
||||||
|
@ -2312,7 +2312,7 @@ f(x) = x \% 100
|
||||||
<a id="__codelineno-22-8" name="__codelineno-22-8" href="#__codelineno-22-8"></a><span class="w"> </span><span class="sd">""" 基于数组简易实现的哈希表 """</span>
|
<a id="__codelineno-22-8" name="__codelineno-22-8" href="#__codelineno-22-8"></a><span class="w"> </span><span class="sd">""" 基于数组简易实现的哈希表 """</span>
|
||||||
<a id="__codelineno-22-9" name="__codelineno-22-9" href="#__codelineno-22-9"></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
<a id="__codelineno-22-9" name="__codelineno-22-9" href="#__codelineno-22-9"></a> <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||||
<a id="__codelineno-22-10" name="__codelineno-22-10" href="#__codelineno-22-10"></a><span class="w"> </span><span class="sd">""" 构造方法 """</span>
|
<a id="__codelineno-22-10" name="__codelineno-22-10" href="#__codelineno-22-10"></a><span class="w"> </span><span class="sd">""" 构造方法 """</span>
|
||||||
<a id="__codelineno-22-11" name="__codelineno-22-11" href="#__codelineno-22-11"></a> <span class="c1"># 初始化一个长度为 100 的桶(数组)</span>
|
<a id="__codelineno-22-11" name="__codelineno-22-11" href="#__codelineno-22-11"></a> <span class="c1"># 初始化数组,包含 100 个桶</span>
|
||||||
<a id="__codelineno-22-12" name="__codelineno-22-12" href="#__codelineno-22-12"></a> <span class="bp">self</span><span class="o">.</span><span class="n">buckets</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">Optional</span><span class="p">[</span><span class="n">Entry</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="mi">100</span>
|
<a id="__codelineno-22-12" name="__codelineno-22-12" href="#__codelineno-22-12"></a> <span class="bp">self</span><span class="o">.</span><span class="n">buckets</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">Optional</span><span class="p">[</span><span class="n">Entry</span><span class="p">]]</span> <span class="o">=</span> <span class="p">[</span><span class="kc">None</span><span class="p">]</span> <span class="o">*</span> <span class="mi">100</span>
|
||||||
<a id="__codelineno-22-13" name="__codelineno-22-13" href="#__codelineno-22-13"></a>
|
<a id="__codelineno-22-13" name="__codelineno-22-13" href="#__codelineno-22-13"></a>
|
||||||
<a id="__codelineno-22-14" name="__codelineno-22-14" href="#__codelineno-22-14"></a> <span class="k">def</span> <span class="nf">hash_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span>
|
<a id="__codelineno-22-14" name="__codelineno-22-14" href="#__codelineno-22-14"></a> <span class="k">def</span> <span class="nf">hash_func</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">:</span> <span class="nb">int</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span>
|
||||||
|
@ -2385,7 +2385,7 @@ f(x) = x \% 100
|
||||||
<a id="__codelineno-23-11" name="__codelineno-23-11" href="#__codelineno-23-11"></a>
|
<a id="__codelineno-23-11" name="__codelineno-23-11" href="#__codelineno-23-11"></a>
|
||||||
<a id="__codelineno-23-12" name="__codelineno-23-12" href="#__codelineno-23-12"></a><span class="cm">/* 初始化哈希表 */</span>
|
<a id="__codelineno-23-12" name="__codelineno-23-12" href="#__codelineno-23-12"></a><span class="cm">/* 初始化哈希表 */</span>
|
||||||
<a id="__codelineno-23-13" name="__codelineno-23-13" href="#__codelineno-23-13"></a><span class="kd">func</span><span class="w"> </span><span class="nx">newArrayHashMap</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="nx">arrayHashMap</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-23-13" name="__codelineno-23-13" href="#__codelineno-23-13"></a><span class="kd">func</span><span class="w"> </span><span class="nx">newArrayHashMap</span><span class="p">()</span><span class="w"> </span><span class="o">*</span><span class="nx">arrayHashMap</span><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-23-14" name="__codelineno-23-14" href="#__codelineno-23-14"></a><span class="w"> </span><span class="c1">// 初始化一个长度为 100 的桶(数组)</span>
|
<a id="__codelineno-23-14" name="__codelineno-23-14" href="#__codelineno-23-14"></a><span class="w"> </span><span class="c1">// 初始化数组,包含 100 个桶</span>
|
||||||
<a id="__codelineno-23-15" name="__codelineno-23-15" href="#__codelineno-23-15"></a><span class="w"> </span><span class="nx">buckets</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nb">make</span><span class="p">([]</span><span class="o">*</span><span class="nx">entry</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p">)</span>
|
<a id="__codelineno-23-15" name="__codelineno-23-15" href="#__codelineno-23-15"></a><span class="w"> </span><span class="nx">buckets</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nb">make</span><span class="p">([]</span><span class="o">*</span><span class="nx">entry</span><span class="p">,</span><span class="w"> </span><span class="mi">100</span><span class="p">)</span>
|
||||||
<a id="__codelineno-23-16" name="__codelineno-23-16" href="#__codelineno-23-16"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="o">&</span><span class="nx">arrayHashMap</span><span class="p">{</span><span class="nx">buckets</span><span class="p">:</span><span class="w"> </span><span class="nx">buckets</span><span class="p">}</span>
|
<a id="__codelineno-23-16" name="__codelineno-23-16" href="#__codelineno-23-16"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="o">&</span><span class="nx">arrayHashMap</span><span class="p">{</span><span class="nx">buckets</span><span class="p">:</span><span class="w"> </span><span class="nx">buckets</span><span class="p">}</span>
|
||||||
<a id="__codelineno-23-17" name="__codelineno-23-17" href="#__codelineno-23-17"></a><span class="p">}</span>
|
<a id="__codelineno-23-17" name="__codelineno-23-17" href="#__codelineno-23-17"></a><span class="p">}</span>
|
||||||
|
@ -2476,7 +2476,7 @@ f(x) = x \% 100
|
||||||
<a id="__codelineno-24-10" name="__codelineno-24-10" href="#__codelineno-24-10"></a><span class="kd">class</span><span class="w"> </span><span class="nx">ArrayHashMap</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-24-10" name="__codelineno-24-10" href="#__codelineno-24-10"></a><span class="kd">class</span><span class="w"> </span><span class="nx">ArrayHashMap</span><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-24-11" name="__codelineno-24-11" href="#__codelineno-24-11"></a><span class="w"> </span><span class="err">#</span><span class="nx">buckets</span><span class="p">;</span>
|
<a id="__codelineno-24-11" name="__codelineno-24-11" href="#__codelineno-24-11"></a><span class="w"> </span><span class="err">#</span><span class="nx">buckets</span><span class="p">;</span>
|
||||||
<a id="__codelineno-24-12" name="__codelineno-24-12" href="#__codelineno-24-12"></a><span class="w"> </span><span class="kr">constructor</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-24-12" name="__codelineno-24-12" href="#__codelineno-24-12"></a><span class="w"> </span><span class="kr">constructor</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-24-13" name="__codelineno-24-13" href="#__codelineno-24-13"></a><span class="w"> </span><span class="c1">// 初始化一个长度为 100 的桶(数组)</span>
|
<a id="__codelineno-24-13" name="__codelineno-24-13" href="#__codelineno-24-13"></a><span class="w"> </span><span class="c1">// 初始化数组,包含 100 个桶</span>
|
||||||
<a id="__codelineno-24-14" name="__codelineno-24-14" href="#__codelineno-24-14"></a><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="mf">100</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
|
<a id="__codelineno-24-14" name="__codelineno-24-14" href="#__codelineno-24-14"></a><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="err">#</span><span class="nx">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="mf">100</span><span class="p">).</span><span class="nx">fill</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
|
||||||
<a id="__codelineno-24-15" name="__codelineno-24-15" href="#__codelineno-24-15"></a><span class="w"> </span><span class="p">}</span>
|
<a id="__codelineno-24-15" name="__codelineno-24-15" href="#__codelineno-24-15"></a><span class="w"> </span><span class="p">}</span>
|
||||||
<a id="__codelineno-24-16" name="__codelineno-24-16" href="#__codelineno-24-16"></a>
|
<a id="__codelineno-24-16" name="__codelineno-24-16" href="#__codelineno-24-16"></a>
|
||||||
|
@ -2568,7 +2568,7 @@ f(x) = x \% 100
|
||||||
<a id="__codelineno-25-15" name="__codelineno-25-15" href="#__codelineno-25-15"></a><span class="w"> </span><span class="k">private</span><span class="w"> </span><span class="k">readonly</span><span class="w"> </span><span class="nx">buckets</span><span class="o">:</span><span class="w"> </span><span class="p">(</span><span class="nx">Entry</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="kc">null</span><span class="p">)[];</span>
|
<a id="__codelineno-25-15" name="__codelineno-25-15" href="#__codelineno-25-15"></a><span class="w"> </span><span class="k">private</span><span class="w"> </span><span class="k">readonly</span><span class="w"> </span><span class="nx">buckets</span><span class="o">:</span><span class="w"> </span><span class="p">(</span><span class="nx">Entry</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="kc">null</span><span class="p">)[];</span>
|
||||||
<a id="__codelineno-25-16" name="__codelineno-25-16" href="#__codelineno-25-16"></a>
|
<a id="__codelineno-25-16" name="__codelineno-25-16" href="#__codelineno-25-16"></a>
|
||||||
<a id="__codelineno-25-17" name="__codelineno-25-17" href="#__codelineno-25-17"></a><span class="w"> </span><span class="kr">constructor</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-25-17" name="__codelineno-25-17" href="#__codelineno-25-17"></a><span class="w"> </span><span class="kr">constructor</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-25-18" name="__codelineno-25-18" href="#__codelineno-25-18"></a><span class="w"> </span><span class="c1">// 初始化一个长度为 100 的桶(数组)</span>
|
<a id="__codelineno-25-18" name="__codelineno-25-18" href="#__codelineno-25-18"></a><span class="w"> </span><span class="c1">// 初始化数组,包含 100 个桶</span>
|
||||||
<a id="__codelineno-25-19" name="__codelineno-25-19" href="#__codelineno-25-19"></a><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="ow">new</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="mf">100</span><span class="p">)).</span><span class="nx">fill</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
|
<a id="__codelineno-25-19" name="__codelineno-25-19" href="#__codelineno-25-19"></a><span class="w"> </span><span class="k">this</span><span class="p">.</span><span class="nx">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="ow">new</span><span class="w"> </span><span class="nb">Array</span><span class="p">(</span><span class="mf">100</span><span class="p">)).</span><span class="nx">fill</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
|
||||||
<a id="__codelineno-25-20" name="__codelineno-25-20" href="#__codelineno-25-20"></a><span class="w"> </span><span class="p">}</span>
|
<a id="__codelineno-25-20" name="__codelineno-25-20" href="#__codelineno-25-20"></a><span class="w"> </span><span class="p">}</span>
|
||||||
<a id="__codelineno-25-21" name="__codelineno-25-21" href="#__codelineno-25-21"></a>
|
<a id="__codelineno-25-21" name="__codelineno-25-21" href="#__codelineno-25-21"></a>
|
||||||
|
@ -2667,7 +2667,7 @@ f(x) = x \% 100
|
||||||
<a id="__codelineno-27-16" name="__codelineno-27-16" href="#__codelineno-27-16"></a><span class="w"> </span><span class="k">private</span><span class="w"> </span><span class="n">List</span><span class="o"><</span><span class="n">Entry</span><span class="o">?></span><span class="w"> </span><span class="n">buckets</span><span class="p">;</span>
|
<a id="__codelineno-27-16" name="__codelineno-27-16" href="#__codelineno-27-16"></a><span class="w"> </span><span class="k">private</span><span class="w"> </span><span class="n">List</span><span class="o"><</span><span class="n">Entry</span><span class="o">?></span><span class="w"> </span><span class="n">buckets</span><span class="p">;</span>
|
||||||
<a id="__codelineno-27-17" name="__codelineno-27-17" href="#__codelineno-27-17"></a><span class="w"> </span><span class="k">public</span><span class="w"> </span><span class="nf">ArrayHashMap</span><span class="p">()</span>
|
<a id="__codelineno-27-17" name="__codelineno-27-17" href="#__codelineno-27-17"></a><span class="w"> </span><span class="k">public</span><span class="w"> </span><span class="nf">ArrayHashMap</span><span class="p">()</span>
|
||||||
<a id="__codelineno-27-18" name="__codelineno-27-18" href="#__codelineno-27-18"></a><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-27-18" name="__codelineno-27-18" href="#__codelineno-27-18"></a><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-27-19" name="__codelineno-27-19" href="#__codelineno-27-19"></a><span class="w"> </span><span class="c1">// 初始化一个长度为 100 的桶(数组)</span>
|
<a id="__codelineno-27-19" name="__codelineno-27-19" href="#__codelineno-27-19"></a><span class="w"> </span><span class="c1">// 初始化数组,包含 100 个桶</span>
|
||||||
<a id="__codelineno-27-20" name="__codelineno-27-20" href="#__codelineno-27-20"></a><span class="w"> </span><span class="n">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="p">();</span>
|
<a id="__codelineno-27-20" name="__codelineno-27-20" href="#__codelineno-27-20"></a><span class="w"> </span><span class="n">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="p">();</span>
|
||||||
<a id="__codelineno-27-21" name="__codelineno-27-21" href="#__codelineno-27-21"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="m">100</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span>
|
<a id="__codelineno-27-21" name="__codelineno-27-21" href="#__codelineno-27-21"></a><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="m">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="m">100</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span>
|
||||||
<a id="__codelineno-27-22" name="__codelineno-27-22" href="#__codelineno-27-22"></a><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-27-22" name="__codelineno-27-22" href="#__codelineno-27-22"></a><span class="w"> </span><span class="p">{</span>
|
||||||
|
@ -2771,7 +2771,7 @@ f(x) = x \% 100
|
||||||
<a id="__codelineno-28-14" name="__codelineno-28-14" href="#__codelineno-28-14"></a> <span class="kd">private</span> <span class="kd">var</span> <span class="nv">buckets</span><span class="p">:</span> <span class="p">[</span><span class="n">Entry</span><span class="p">?]</span> <span class="p">=</span> <span class="p">[]</span>
|
<a id="__codelineno-28-14" name="__codelineno-28-14" href="#__codelineno-28-14"></a> <span class="kd">private</span> <span class="kd">var</span> <span class="nv">buckets</span><span class="p">:</span> <span class="p">[</span><span class="n">Entry</span><span class="p">?]</span> <span class="p">=</span> <span class="p">[]</span>
|
||||||
<a id="__codelineno-28-15" name="__codelineno-28-15" href="#__codelineno-28-15"></a>
|
<a id="__codelineno-28-15" name="__codelineno-28-15" href="#__codelineno-28-15"></a>
|
||||||
<a id="__codelineno-28-16" name="__codelineno-28-16" href="#__codelineno-28-16"></a> <span class="kd">init</span><span class="p">()</span> <span class="p">{</span>
|
<a id="__codelineno-28-16" name="__codelineno-28-16" href="#__codelineno-28-16"></a> <span class="kd">init</span><span class="p">()</span> <span class="p">{</span>
|
||||||
<a id="__codelineno-28-17" name="__codelineno-28-17" href="#__codelineno-28-17"></a> <span class="c1">// 初始化一个长度为 100 的桶(数组)</span>
|
<a id="__codelineno-28-17" name="__codelineno-28-17" href="#__codelineno-28-17"></a> <span class="c1">// 初始化数组,包含 100 个桶</span>
|
||||||
<a id="__codelineno-28-18" name="__codelineno-28-18" href="#__codelineno-28-18"></a> <span class="k">for</span> <span class="kc">_</span> <span class="k">in</span> <span class="mi">0</span> <span class="p">..</span><span class="o"><</span> <span class="mi">100</span> <span class="p">{</span>
|
<a id="__codelineno-28-18" name="__codelineno-28-18" href="#__codelineno-28-18"></a> <span class="k">for</span> <span class="kc">_</span> <span class="k">in</span> <span class="mi">0</span> <span class="p">..</span><span class="o"><</span> <span class="mi">100</span> <span class="p">{</span>
|
||||||
<a id="__codelineno-28-19" name="__codelineno-28-19" href="#__codelineno-28-19"></a> <span class="n">buckets</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="kc">nil</span><span class="p">)</span>
|
<a id="__codelineno-28-19" name="__codelineno-28-19" href="#__codelineno-28-19"></a> <span class="n">buckets</span><span class="p">.</span><span class="n">append</span><span class="p">(</span><span class="kc">nil</span><span class="p">)</span>
|
||||||
<a id="__codelineno-28-20" name="__codelineno-28-20" href="#__codelineno-28-20"></a> <span class="p">}</span>
|
<a id="__codelineno-28-20" name="__codelineno-28-20" href="#__codelineno-28-20"></a> <span class="p">}</span>
|
||||||
|
@ -2871,7 +2871,7 @@ f(x) = x \% 100
|
||||||
<a id="__codelineno-29-22" name="__codelineno-29-22" href="#__codelineno-29-22"></a><span class="w"> </span><span class="c1">// 构造方法</span>
|
<a id="__codelineno-29-22" name="__codelineno-29-22" href="#__codelineno-29-22"></a><span class="w"> </span><span class="c1">// 构造方法</span>
|
||||||
<a id="__codelineno-29-23" name="__codelineno-29-23" href="#__codelineno-29-23"></a><span class="w"> </span><span class="kr">pub</span><span class="w"> </span><span class="k">fn</span><span class="w"> </span><span class="n">init</span><span class="p">(</span><span class="n">self</span><span class="o">:</span><span class="w"> </span><span class="o">*</span><span class="n">Self</span><span class="p">,</span><span class="w"> </span><span class="n">allocator</span><span class="o">:</span><span class="w"> </span><span class="n">std</span><span class="p">.</span><span class="n">mem</span><span class="p">.</span><span class="n">Allocator</span><span class="p">)</span><span class="w"> </span><span class="o">!</span><span class="kt">void</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-29-23" name="__codelineno-29-23" href="#__codelineno-29-23"></a><span class="w"> </span><span class="kr">pub</span><span class="w"> </span><span class="k">fn</span><span class="w"> </span><span class="n">init</span><span class="p">(</span><span class="n">self</span><span class="o">:</span><span class="w"> </span><span class="o">*</span><span class="n">Self</span><span class="p">,</span><span class="w"> </span><span class="n">allocator</span><span class="o">:</span><span class="w"> </span><span class="n">std</span><span class="p">.</span><span class="n">mem</span><span class="p">.</span><span class="n">Allocator</span><span class="p">)</span><span class="w"> </span><span class="o">!</span><span class="kt">void</span><span class="w"> </span><span class="p">{</span>
|
||||||
<a id="__codelineno-29-24" name="__codelineno-29-24" href="#__codelineno-29-24"></a><span class="w"> </span><span class="n">self</span><span class="p">.</span><span class="n">mem_allocator</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">allocator</span><span class="p">;</span>
|
<a id="__codelineno-29-24" name="__codelineno-29-24" href="#__codelineno-29-24"></a><span class="w"> </span><span class="n">self</span><span class="p">.</span><span class="n">mem_allocator</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">allocator</span><span class="p">;</span>
|
||||||
<a id="__codelineno-29-25" name="__codelineno-29-25" href="#__codelineno-29-25"></a><span class="w"> </span><span class="c1">// 初始化一个长度为 100 的桶(数组)</span>
|
<a id="__codelineno-29-25" name="__codelineno-29-25" href="#__codelineno-29-25"></a><span class="w"> </span><span class="c1">// 初始化数组,包含 100 个桶</span>
|
||||||
<a id="__codelineno-29-26" name="__codelineno-29-26" href="#__codelineno-29-26"></a><span class="w"> </span><span class="n">self</span><span class="p">.</span><span class="n">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">std</span><span class="p">.</span><span class="n">ArrayList</span><span class="p">(</span><span class="o">?</span><span class="n">T</span><span class="p">).</span><span class="n">init</span><span class="p">(</span><span class="n">self</span><span class="p">.</span><span class="n">mem_allocator</span><span class="p">);</span>
|
<a id="__codelineno-29-26" name="__codelineno-29-26" href="#__codelineno-29-26"></a><span class="w"> </span><span class="n">self</span><span class="p">.</span><span class="n">buckets</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">std</span><span class="p">.</span><span class="n">ArrayList</span><span class="p">(</span><span class="o">?</span><span class="n">T</span><span class="p">).</span><span class="n">init</span><span class="p">(</span><span class="n">self</span><span class="p">.</span><span class="n">mem_allocator</span><span class="p">);</span>
|
||||||
<a id="__codelineno-29-27" name="__codelineno-29-27" href="#__codelineno-29-27"></a><span class="w"> </span><span class="kr">var</span><span class="w"> </span><span class="n">i</span><span class="o">:</span><span class="w"> </span><span class="kt">i32</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
|
<a id="__codelineno-29-27" name="__codelineno-29-27" href="#__codelineno-29-27"></a><span class="w"> </span><span class="kr">var</span><span class="w"> </span><span class="n">i</span><span class="o">:</span><span class="w"> </span><span class="kt">i32</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
|
||||||
<a id="__codelineno-29-28" name="__codelineno-29-28" href="#__codelineno-29-28"></a><span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="mi">100</span><span class="p">)</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
|
<a id="__codelineno-29-28" name="__codelineno-29-28" href="#__codelineno-29-28"></a><span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o"><</span><span class="w"> </span><span class="mi">100</span><span class="p">)</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="w"> </span><span class="o">+=</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
|
||||||
|
|
File diff suppressed because one or more lines are too long
BIN
sitemap.xml.gz
BIN
sitemap.xml.gz
Binary file not shown.
Loading…
Reference in a new issue