diff options
author | Guido van Rossum <guido@python.org> | 2000-02-02 15:10:15 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-02-02 15:10:15 (GMT) |
commit | 4acc25bd392216c4f867a10ca8081e7c8a739676 (patch) | |
tree | db4976fa172404339b31aa7485a5316634e4c699 /Lib/bisect.py | |
parent | 113e70efa2b932a3ad2662875114133a1edb600c (diff) | |
download | cpython-4acc25bd392216c4f867a10ca8081e7c8a739676.zip cpython-4acc25bd392216c4f867a10ca8081e7c8a739676.tar.gz cpython-4acc25bd392216c4f867a10ca8081e7c8a739676.tar.bz2 |
Mass patch by Ka-Ping Yee:
1. Comments at the beginning of the module, before
functions, and before classes have been turned
into docstrings.
2. Tabs are normalized to four spaces.
Also, removed the "remove" function from dircmp.py, which reimplements
list.remove() (it must have been very old).
Diffstat (limited to 'Lib/bisect.py')
-rw-r--r-- | Lib/bisect.py | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/Lib/bisect.py b/Lib/bisect.py index 5fbc4ef..47ef509 100644 --- a/Lib/bisect.py +++ b/Lib/bisect.py @@ -1,25 +1,23 @@ -# Bisection algorithms +"""Bisection algorithms.""" -# Insert item x in list a, and keep it sorted assuming a is sorted - def insort(a, x, lo=0, hi=None): - if hi is None: - hi = len(a) - while lo < hi: - mid = (lo+hi)/2 - if x < a[mid]: hi = mid - else: lo = mid+1 - a.insert(lo, x) - + """Insert item x in list a, and keep it sorted assuming a is sorted.""" + if hi is None: + hi = len(a) + while lo < hi: + mid = (lo+hi)/2 + if x < a[mid]: hi = mid + else: lo = mid+1 + a.insert(lo, x) -# Find the index where to insert item x in list a, assuming a is sorted def bisect(a, x, lo=0, hi=None): - if hi is None: - hi = len(a) - while lo < hi: - mid = (lo+hi)/2 - if x < a[mid]: hi = mid - else: lo = mid+1 - return lo + """Find the index where to insert item x in list a, assuming a is sorted.""" + if hi is None: + hi = len(a) + while lo < hi: + mid = (lo+hi)/2 + if x < a[mid]: hi = mid + else: lo = mid+1 + return lo |