用法:
class queue.PriorityQueue(maxsize=0)
優先級隊列的構造函數。
maxsize
是一個整數,用於設置可放入隊列中的項目數的上限。一旦達到這個大小,插入將被阻塞,直到隊列項目被消耗。如果maxsize
小於或等於零,則隊列大小是無限的。首先檢索最低值的條目(最低值的條目是
sorted(list(entries))[0]
返回的條目)。條目的典型模式是以下形式的元組:(priority_number, data)
。如果
data
元素不可比較,則可以將數據包裝在忽略數據項並僅比較優先級編號的類中:from dataclasses import dataclass, field from typing import Any @dataclass(order=True) class PrioritizedItem: priority: int item: Any=field(compare=False)
相關用法
- Python cudf.core.column.string.StringMethods.is_vowel用法及代碼示例
- Python torch.distributed.rpc.rpc_async用法及代碼示例
- Python torch.nn.InstanceNorm3d用法及代碼示例
- Python sklearn.cluster.MiniBatchKMeans用法及代碼示例
- Python pandas.arrays.IntervalArray.is_empty用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python numpy.less()用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python Sympy Permutation.list()用法及代碼示例
- Python dask.dataframe.Series.apply用法及代碼示例
- Python scipy.ndimage.binary_opening用法及代碼示例
- Python pyspark.pandas.Series.dropna用法及代碼示例
- Python torchaudio.transforms.Fade用法及代碼示例
- Python dask.dataframe.to_records用法及代碼示例
- Python pyspark.pandas.groupby.SeriesGroupBy.unique用法及代碼示例
- Python distributed.protocol.serialize.register_generic用法及代碼示例
- Python numpy.polynomial.hermite.hermmul用法及代碼示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代碼示例
- Python dask.dataframe.DataFrame.applymap用法及代碼示例
- Python tf.summary.scalar用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 queue.PriorityQueue。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。