__init__.py 文件源码

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

项目:ScenicOverlook 作者: pschanely 项目源码 文件源码
def _merge_sorted_lists(keyfn):
    def merge(l1, l2):
        # TODO might be nice to have a specialized version of this which
        # re-uses uninterrupted subtrees from one side; it would boost
        # lists that are mostly sorted already.
        min1, max1 = keyfn(l1[0]), keyfn(l1[-1])
        min2, max2 = keyfn(l2[0]), keyfn(l2[-1])
        if max1 <= min2:
            return l1 + l2
        if max2 < min1: # not "<=" here because it would make the sort unstable
            return l2 + l1
        return viewablelist(list(_mergesorted(iter(l1), iter(l2), keyfn)))
    return merge



#
#  Other
#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号