MCPcopy
hub / github.com/django/django / bisect_keep_left

Function bisect_keep_left

django/contrib/messages/storage/cookie.py:217–231  ·  view source on GitHub ↗

Find the index of the first element from the start of the array that verifies the given condition. The function is applied from the start of the array to the pivot.

(a, fn)

Source from the content-addressed store, hash-verified

215
216
217def bisect_keep_left(a, fn):
218 """
219 Find the index of the first element from the start of the array that
220 verifies the given condition.
221 The function is applied from the start of the array to the pivot.
222 """
223 lo = 0
224 hi = len(a)
225 while lo < hi:
226 mid = (lo + hi) // 2
227 if fn(a[: mid + 1]):
228 hi = mid
229 else:
230 lo = mid + 1
231 return lo
232
233
234def bisect_keep_right(a, fn):

Callers 2

test_bisect_keep_leftMethod · 0.90
_storeMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_bisect_keep_leftMethod · 0.72