-
-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathbisect.po
More file actions
291 lines (260 loc) · 12.7 KB
/
bisect.po
File metadata and controls
291 lines (260 loc) · 12.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
# Translators:
# 周 忠毅 <[email protected]>, 2016
# Liang-Bo Wang <[email protected]>, 2017
# pertertc <[email protected]>, 2022
# Matt Wang <[email protected]>, 2022
msgid ""
msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-17 17:39+0800\n"
"PO-Revision-Date: 2023-08-01 12:53+0800\n"
"Last-Translator: Matt Wang <[email protected]>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
"Language: zh_TW\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 3.3.2\n"
#: ../../library/bisect.rst:2
msgid ":mod:`bisect` --- Array bisection algorithm"
msgstr ":mod:`bisect` --- 陣列二分演算法 (Array bisection algorithm)"
#: ../../library/bisect.rst:10
msgid "**Source code:** :source:`Lib/bisect.py`"
msgstr "**原始碼:**\\ :source:`Lib/bisect.py`"
#: ../../library/bisect.rst:14
msgid ""
"This module provides support for maintaining a list in sorted order without "
"having to sort the list after each insertion. For long lists of items with "
"expensive comparison operations, this can be an improvement over linear "
"searches or frequent resorting."
msgstr ""
"這個模組維護一個已經排序過的 list ,當我們每次做完插入後不需要再次排序整個 "
"list 。一個很長的 list 的比較操作很花費時間,可以透過線性搜索或頻繁地詢問來改"
"善。"
#: ../../library/bisect.rst:19
msgid ""
"The module is called :mod:`bisect` because it uses a basic bisection "
"algorithm to do its work. Unlike other bisection tools that search for a "
"specific value, the functions in this module are designed to locate an "
"insertion point. Accordingly, the functions never call an :meth:`__eq__` "
"method to determine whether a value has been found. Instead, the functions "
"only call the :meth:`__lt__` method and will return an insertion point "
"between values in an array."
msgstr ""
"這個模組被稱為 :mod:`bisect` 是因為它使用基本二分演算法來完成其工作。不像其它搜尋"
"特定值的二分法工具,本模組中的函式旨在定位插入點。因此,這些函式永遠不會呼"
"叫 :meth:`__eq__` 方法來確認是否找到一個值。相反地,這些函式只呼叫 :meth:"
"`__lt__` 方法,並在陣列中的值回傳一個插入點。"
#: ../../library/bisect.rst:29
msgid "The following functions are provided:"
msgstr "此模組提供下面的函式:"
#: ../../library/bisect.rst:34
msgid ""
"Locate the insertion point for *x* in *a* to maintain sorted order. The "
"parameters *lo* and *hi* may be used to specify a subset of the list which "
"should be considered; by default the entire list is used. If *x* is already "
"present in *a*, the insertion point will be before (to the left of) any "
"existing entries. The return value is suitable for use as the first "
"parameter to ``list.insert()`` assuming that *a* is already sorted."
msgstr ""
"在 *a* 當中找到一個位置,讓 *x* 插入後 *a* 仍然是排序好的。參數 *lo* 和 *hi* "
"用來指定 list 中應該被考慮的子區間,預設是考慮整個 list 。如果 *a* 裡面已經"
"有 *x* 出現,插入的位置會在所有 *x* 的前面(左邊)。回傳值可以被當作 ``list."
"insert()`` 的第一個參數,但列表 *a* 必須先排序過。"
#: ../../library/bisect.rst:41
msgid ""
"The returned insertion point *ip* partitions the array *a* into two slices "
"such that ``all(elem < x for elem in a[lo : ip])`` is true for the left "
"slice and ``all(elem >= x for elem in a[ip : hi])`` is true for the right "
"slice."
msgstr ""
"回傳的插入點 *ip* 將陣列 *a* 劃分為左右兩個切片,使得對於左切片而言 "
"``all(elem < x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem >= "
"x for elem in a[ip : hi])`` 為真。"
#: ../../library/bisect.rst:46
msgid ""
"*key* specifies a :term:`key function` of one argument that is used to "
"extract a comparison key from each element in the array. To support "
"searching complex records, the key function is not applied to the *x* value."
msgstr ""
"*key* 可指定一個單一參數的 :term:`key function`。函式將套用此 function 在陣列"
"所有元素以得到比較值來計算順位。注意此 function 只會套用在陣列中的元素,不會"
"套用在 *x*。"
#: ../../library/bisect.rst:50
msgid ""
"If *key* is ``None``, the elements are compared directly and no key function "
"is called."
msgstr "若 *key* 為 ``None``,元素將直接進行比較,不會呼叫任何鍵函式。"
#: ../../library/bisect.rst:53 ../../library/bisect.rst:67
#: ../../library/bisect.rst:85 ../../library/bisect.rst:105
msgid "Added the *key* parameter."
msgstr "新增 *key* 參數。"
#: ../../library/bisect.rst:60
msgid ""
"Similar to :py:func:`~bisect.bisect_left`, but returns an insertion point "
"which comes after (to the right of) any existing entries of *x* in *a*."
msgstr ""
"類似 :py:func:`~bisect.bisect_left`,但回傳的插入位置會在所有 *a* 當中的 *x* "
"的後面(右邊)。"
#: ../../library/bisect.rst:63
msgid ""
"The returned insertion point *ip* partitions the array *a* into two slices "
"such that ``all(elem <= x for elem in a[lo : ip])`` is true for the left "
"slice and ``all(elem > x for elem in a[ip : hi])`` is true for the right "
"slice."
msgstr ""
"回傳的插入點 *ip* 將陣列 *a* 劃分為左右兩個切片,使得對於左切片而言 "
"``all(elem <= x for elem in a[lo : ip])`` 為真,對於右切片而言 ``all(elem > "
"x for elem in a[ip : hi])`` 為真。"
#: ../../library/bisect.rst:73
msgid "Insert *x* in *a* in sorted order."
msgstr "將元素 *x* 插入 list *a*,並維持順序。"
#: ../../library/bisect.rst:75
msgid ""
"This function first runs :py:func:`~bisect.bisect_left` to locate an "
"insertion point. Next, it runs the :meth:`insert` method on *a* to insert "
"*x* at the appropriate position to maintain sort order."
msgstr ""
"此函式先使用 :py:func:`~bisect.bisect_left` 搜索插入位置,接著用 :meth:"
"`insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。"
#: ../../library/bisect.rst:79 ../../library/bisect.rst:99
msgid ""
"To support inserting records in a table, the *key* function (if any) is "
"applied to *x* for the search step but not for the insertion step."
msgstr "此函式只有在搜索時會使用 *key* 函式,插入時不會。"
#: ../../library/bisect.rst:82 ../../library/bisect.rst:102
msgid ""
"Keep in mind that the ``O(log n)`` search is dominated by the slow O(n) "
"insertion step."
msgstr ""
"注意雖然搜索是 ``O(log n)``,但插入是 O(n),因此此函式整體時間複雜度是 O(n)。"
#: ../../library/bisect.rst:92
msgid ""
"Similar to :py:func:`~bisect.insort_left`, but inserting *x* in *a* after "
"any existing entries of *x*."
msgstr ""
"類似 :py:func:`~bisect.insort_left`,但插入的位置會在所有 *a* 當中的 *x* 的後"
"面(右邊)。"
#: ../../library/bisect.rst:95
msgid ""
"This function first runs :py:func:`~bisect.bisect_right` to locate an "
"insertion point. Next, it runs the :meth:`insert` method on *a* to insert "
"*x* at the appropriate position to maintain sort order."
msgstr ""
"此函式先使用 :py:func:`~bisect.bisect_right` 搜索插入位置,接著用 :meth:"
"`insert` 於 *a* 以將 *x* 插入,並維持添加元素後的順序。"
#: ../../library/bisect.rst:110
msgid "Performance Notes"
msgstr "效能考量"
#: ../../library/bisect.rst:112
msgid ""
"When writing time sensitive code using *bisect()* and *insort()*, keep these "
"thoughts in mind:"
msgstr ""
"若在需要關注寫入時間的程式當中使用 *bisect()* 和 *insort()*,請特別注意幾個事"
"項:"
#: ../../library/bisect.rst:115
msgid ""
"Bisection is effective for searching ranges of values. For locating specific "
"values, dictionaries are more performant."
msgstr ""
"二分法在一段範圍的數值中做搜索的效率較佳,但若是要存取特定數值,使用字典的表"
"現還是比較好。"
#: ../../library/bisect.rst:118
msgid ""
"The *insort()* functions are ``O(n)`` because the logarithmic search step is "
"dominated by the linear time insertion step."
msgstr ""
"*insort()* 函式的複雜度為 ``O(n)``,因為對數搜尋是以線性時間的插入步驟所主導 "
"(dominate)。"
#: ../../library/bisect.rst:121
msgid ""
"The search functions are stateless and discard key function results after "
"they are used. Consequently, if the search functions are used in a loop, "
"the key function may be called again and again on the same array elements. "
"If the key function isn't fast, consider wrapping it with :py:func:"
"`functools.cache` to avoid duplicate computations. Alternatively, consider "
"searching an array of precomputed keys to locate the insertion point (as "
"shown in the examples section below)."
msgstr ""
"搜索函式為無狀態的 (stateless),且鍵函式會在使用過後被丟棄。因此,如果搜索函"
"式被使用於迴圈當中,鍵函式會不斷被重複呼叫於相同的 list 元素。如果鍵函式執行"
"速度不快,請考慮將其以 :py:func:`functools.cache` 包裝起來以減少重複的計算。"
"另外,也可以透過搜尋預先計算好的鍵列表 (array of precomputed keys) 來定位插入"
"點(如下方範例所示)。"
#: ../../library/bisect.rst:131
msgid ""
"`Sorted Collections <https://grantjenks.com/docs/sortedcollections/>`_ is a "
"high performance module that uses *bisect* to managed sorted collections of "
"data."
msgstr ""
"`有序容器 (Sorted Collections) <https://grantjenks.com/docs/"
"sortedcollections/>`_ 是一個使用 *bisect* 來管理資料之有序集合的高效能模組。"
#: ../../library/bisect.rst:135
msgid ""
"The `SortedCollection recipe <https://code.activestate.com/recipes/577197-"
"sortedcollection/>`_ uses bisect to build a full-featured collection class "
"with straight-forward search methods and support for a key-function. The "
"keys are precomputed to save unnecessary calls to the key function during "
"searches."
msgstr ""
"`SortedCollection recipe <https://code.activestate.com/recipes/577197-"
"sortedcollection/>`_ 使用二分法來建立一個功能完整的集合類別 (collection "
"class) 並帶有符合直覺的搜索方法 (search methods) 與支援鍵函式。鍵會預先被計算"
"好,以減少搜索過程中多餘的鍵函式呼叫。"
#: ../../library/bisect.rst:143
msgid "Searching Sorted Lists"
msgstr "搜尋一個已排序的 list"
#: ../../library/bisect.rst:145
msgid ""
"The above `bisect functions`_ are useful for finding insertion points but "
"can be tricky or awkward to use for common searching tasks. The following "
"five functions show how to transform them into the standard lookups for "
"sorted lists::"
msgstr ""
"上面的 `bisect functions`_ 在找到數值插入點上很有用,但一般的數值搜尋任務上就"
"不是那麼的方便。以下的五個函式展示了如何將其轉換成標準的有序列表查找函式:\n"
"\n"
"::"
#: ../../library/bisect.rst:187
msgid "Examples"
msgstr "範例"
#: ../../library/bisect.rst:191
msgid ""
"The :py:func:`~bisect.bisect` function can be useful for numeric table "
"lookups. This example uses :py:func:`~bisect.bisect` to look up a letter "
"grade for an exam score (say) based on a set of ordered numeric breakpoints: "
"90 and up is an 'A', 80 to 89 is a 'B', and so on::"
msgstr ""
":py:func:`~bisect.bisect` 函式可用於數值表中的查找 (numeric table lookup),這"
"個範例使用 :py:func:`~bisect.bisect` 以基於一組有序的數值分界點來為一個考試成"
"績找到相對應的字母等級:90 以上是 'A'、80 到 89 為 'B',依此類推:\n"
"\n"
"::"
#: ../../library/bisect.rst:203
msgid ""
"The :py:func:`~bisect.bisect` and :py:func:`~bisect.insort` functions also "
"work with lists of tuples. The *key* argument can serve to extract the "
"field used for ordering records in a table::"
msgstr ""
":py:func:`~bisect.bisect` 與 :py:func:`~bisect.insort` 函式也適用於內容為 "
"tuples(元組)的 lists,*key* 引數可被用以取出在數值表中作為排序依據的欄"
"位:\n"
"\n"
"::"
#: ../../library/bisect.rst:237
msgid ""
"If the key function is expensive, it is possible to avoid repeated function "
"calls by searching a list of precomputed keys to find the index of a record::"
msgstr ""
"如果鍵函式會消耗較多運算資源,那可以在預先計算好的鍵列表中搜索該紀錄的索引"
"值,以減少重複的函式呼叫:\n"
"\n"
"::"