8000 Adds more translations of Theory of heapq (#431) · python/python-docs-zh-tw@8937bdf · GitHub
[go: up one dir, main page]

Skip to content

Commit 8937bdf

Browse files
authored
Adds more translations of Theory of heapq (#431)
1 parent 4b553aa commit 8937bdf

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

library/heapq.po

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ msgstr ""
1010
"Project-Id-Version: Python 3.11\n"
1111
"Report-Msgid-Bugs-To: \n"
1212
"POT-Creation-Date: 2018-10-19 17:24+0800\n"
13-
"PO-Revision-Date: 2023-06-29 12:10+0800\n"
13+
"PO-Revision-Date: 2023-06-30 23:05+0800\n"
1414
"Last-Translator: Liang-Bo Wang <me@liang2.tw>\n"
1515
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
1616
"tw)\n"
@@ -400,6 +400,11 @@ msgid ""
400400
"logarithmic on the total number of items in the tree. By iterating over all "
401401
"items, you get an O(n log n) sort."
402402
msgstr ""
403+
"如果能確保滿足這個 heap 的不變式,那麼索引 0 顯然是最終的贏家。移除並找到「下"
404+
"一個」贏家最簡單的演算法為:將一個輸家(例如上圖中的單元 30)移動到位置 0,然"
405+
"後從新的位置 0 不斷與下方的位置交換值來向下傳遞,直到滿足不變式為止。這個過程"
406+
"的複雜度顯然是樹的節點數目的對數級別。透過對所有項目疊代,可以得到一個複雜度"
407+
"為 O(n log n) 的排序。"
403408

404409
#: ../../library/heapq.rst:275
405410
msgid ""
@@ -412,6 +417,11 @@ msgid ""
412417
"they can easily go into the heap. So, a heap is a good structure for "
413418
"implementing schedulers (this is what I used for my MIDI sequencer :-)."
414419
msgstr ""
420+
"這種排序有個好處,只要插入的項目沒有「贏過」你最後提取、索引為 0 的元素,你就"
421+
"可以在排序進行的同時有效率地插入新項目。這在模擬情境當中特別有用,其中樹能夠"
422+
"保存所有輸入事件,而「贏」意味著最小排程時間。當一個事件排程其它事件的執行"
423+
"時,因這些事件仍在等待進行,所以很容易將它們插入 heap 當中。因此, heap 是一"
424+
"個實現排程器的優秀資料結構(這就是我用以實作 MIDI 編曲器的方法 :-)。"
415425

416426
#: ../../library/heapq.rst:284
417427
msgid ""
@@ -421,6 +431,9 @@ msgid ""
421431
"average case. However, there are other representations which are more "
422432
"efficient overall, yet the worst cases might be terrible."
423433
msgstr ""
434+
"多種用於實作排程器的結構現今已被廣泛研究,heap 對此非常有用,因為它們速度相當"
435+
"快,且速度幾乎不受其他因素影響,最壞情況與平均狀況差異無幾。也有其它整體說來"
436+
"更有效率的方法,然而它們的最壞情況可能會非常糟糕。"
424437

425438
#: ../../library/heapq.rst:290
426439
msgid ""
@@ -435,6 +448,13 @@ msgid ""
435448
"which are twice the size of the memory for random input, and much better for "
436449
"input fuzzily ordered."
437450
msgstr ""
451+
"Heap 在為儲存於硬碟上的大量資料進行排序也非常有用。你可能已經知道,大量資料排"
452+
"序涉及 \"runs\" 的產生(也就是預先排序的序列,其大小通常與 CPU 記憶體的大小有"
453+
"關),之後再對這些 run 合併,而這些合併的過程通常相當巧妙 [#]_。很重要的一點"
454+
"是,初始排序產生的 run 越長越好。錦標賽是達成這一點的好方法,若你用所有可用記"
455+
"憶體來舉行一場錦標賽,並透過替換與向下交換來處理所有適配當前 run 的值,那麼對"
456+
"於隨機產生的輸入,將可以產生長度兩倍於記憶體大小的 run。對於已模糊排序過的輸"
457+
"入,效果更好。"
438458

439459
#: ../../library/heapq.rst:300
440460
msgid ""
@@ -446,12 +466,19 @@ msgid ""
446466
"the first heap is melting. When the first heap completely vanishes, you "
447467
"switch heaps and start a new run. Clever and quite effective!"
448468
msgstr ""
469+
"此外,若你將索引為 0 的項目輸出至磁碟,並取得一個無法適配當前錦標賽的輸入(因"
470+
"為該值「勝過」最後的輸出值),則該輸入值就無法插入至 heap 當中,因此 heap 的"
471+
"大小會減小。釋放出來的記憶體可以巧妙地立即再被運用,逐步建構出第二個 heap,其"
472+
"大小增加的速度會與第一個 heap 減少的速度一致。當第一個 heap 完全消失時,你可"
473+
"以切換至第二個 heap 開啟一個新 run 。這真是個聰明且相當有效率的做法!"
449474

450475
#: ../../library/heapq.rst:308
451476
msgid ""
452477
"In a word, heaps are useful memory structures to know. I use them in a few "
453478
"applications, and I think it is good to keep a 'heap' module around. :-)"
454479
msgstr ""
480+
"總結來說,heap 是值得了解的有用記憶體結構。我在一些應用中使用它們,我認為能有"
481+
"一個 'heap' 模組是很棒的。:-)"
455482

456483
#: ../../library/heapq.rst:312
457484
msgid "Footnotes"
@@ -469,3 +496,8 @@ msgid ""
469496
"Believe me, real good tape sorts were quite spectacular to watch! From all "
470497
"times, sorting has always been a Great Art! :-)"
471498
msgstr ""
499+
"現今的磁碟平衡演算法因為硬碟查找能力而更加複雜難解。在沒有查找功能的裝置如大"
500+
"型磁帶機,狀況又不一樣了,人們必須機智地確保(遠遠提前)每次於磁帶上移動都盡"
501+
"可能是最有效率的(也就是盡可能更好地「推進」合併的過程)。有些磁帶甚至能夠向"
502+
"後讀取,這也被用來避免倒轉的時間。相信我,真正優秀的磁帶排序看起來相當壯觀!"
503+
"排序一直以來都是一門偉大的藝術!:-)"

0 commit comments

Comments
 (0)
0