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