同步操作将从 OpenHarmony-SIG/python 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
"""Bisection algorithms."""def insort_right(a, x, lo=0, hi=None):"""Insert item x in list a, and keep it sorted assuming a is sorted.If x is already in a, insert it to the right of the rightmost x.Optional args lo (default 0) and hi (default len(a)) bound theslice of a to be searched."""lo = bisect_right(a, x, lo, hi)a.insert(lo, x)def bisect_right(a, x, lo=0, hi=None):"""Return the index where to insert item x in list a, assuming a is sorted.The return value i is such that all e in a[:i] have e <= x, and all e ina[i:] have e > x. So if x already appears in the list, a.insert(x) willinsert just after the rightmost x already there.Optional args lo (default 0) and hi (default len(a)) bound theslice of a to be searched."""if lo < 0:raise ValueError('lo must be non-negative')if hi is None:hi = len(a)while lo < hi:mid = (lo+hi)//2if x < a[mid]: hi = midelse: lo = mid+1return lodef insort_left(a, x, lo=0, hi=None):"""Insert item x in list a, and keep it sorted assuming a is sorted.If x is already in a, insert it to the left of the leftmost x.Optional args lo (default 0) and hi (default len(a)) bound theslice of a to be searched."""lo = bisect_left(a, x, lo, hi)a.insert(lo, x)def bisect_left(a, x, lo=0, hi=None):"""Return the index where to insert item x in list a, assuming a is sorted.The return value i is such that all e in a[:i] have e < x, and all e ina[i:] have e >= x. So if x already appears in the list, a.insert(x) willinsert just before the leftmost x already there.Optional args lo (default 0) and hi (default len(a)) bound theslice of a to be searched."""if lo < 0:raise ValueError('lo must be non-negative')if hi is None:hi = len(a)while lo < hi:mid = (lo+hi)//2if a[mid] < x: lo = mid+1else: hi = midreturn lo# Overwrite above definitions with a fast C implementationtry:from _bisect import *except ImportError:pass# Create aliasesbisect = bisect_rightinsort = insort_right
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。