File tree Expand file tree Collapse file tree 2 files changed +3
-2
lines changed Expand file tree Collapse file tree 2 files changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ list.index()无法应对大规模数据的查询,需要用其它方法解决
7474
7575- 模块接受排序后的列表。
7676- 本模块同样适用于长列表项。因为它就是用二分查找方法实现的,有兴趣可以看其源码(源码是一个很好的二分查找算法的例子,特别是很好地解决了边界条件极端的问题.)
77- - 关于bisect模块的更多内容,可以参看官方文档
77+ - 关于bisect模块的更多内容,可以参看 [ 官方文档 ] ( https://docs.python.org/2/library/bisect.html )
7878
7979下面演示这个模块的一个函数
8080
Original file line number Diff line number Diff line change @@ -74,13 +74,14 @@ def bsearch(l, value):
7474
7575- 本模块同样适用于长列表项。因为它就是用二分查找方法实现的,有兴趣可以看其源码(源码是一个很好的二分查找算法的例子,特别是很好地解决了边界条件极端的问题.)
7676
77+ -关于本模块,可以查看官方文档:https://docs.python.org/2/library/bisect.html
7778"""
7879#下面演示这个模块
7980
8081from bisect import *
8182
8283def bisectSearch (lst , x ):
83- i = bisect_left (lst , x )
84+ i = bisect_left (lst , x ) #bisect_left(lst,x)得到x在已经排序的lst中的位置
8485 if i != len (lst ) and lst [i ] == x :
8586 return i
8687
You can’t perform that action at this time.
0 commit comments