caching.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:Chorus 作者: DonaldBough 项目源码 文件源码
def insort_right_rev(alist, new_element, low=0, high=None):
    """Similar to bisect.insort_right but for reverse sorted lists

    This code is similar to the Python code found in Lib/bisect.py.
    We simply change the comparison from 'less than' to 'greater than'.
    """

    if low < 0:
        raise ValueError('low must be non-negative')
    if high is None:
        high = len(alist)
    while low < high:
        middle = (low + high) // 2
        if new_element > alist[middle]:
            high = middle
        else:
            low = middle + 1
    alist.insert(low, new_element)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号