def register(item, category, weight):
entry = Registry._registered_categories.get(category)
category_list = entry[0] if entry else None
weight_table = entry[1] if entry else None
if not category_list:
category_list = []
if not weight_table:
weight_table = []
if (item, weight) not in category_list:
category_list.append((weight, item))
weight_table = list(accumulate([i[0] for i in category_list]))
Registry._registered_categories[category] = category_list, weight_table
评论列表
文章目录