MCPcopy
hub / github.com/django/django / bisect_keep_right

Function bisect_keep_right

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

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

(a, fn)

Source from the content-addressed store, hash-verified

232
233
234def bisect_keep_right(a, fn):
235 """
236 Find the index of the first element from the end of the array that verifies
237 the given condition.
238 The function is applied from the pivot to the end of array.
239 """
240 lo = 0
241 hi = len(a)
242 while lo < hi:
243 mid = (lo + hi) // 2
244 if fn(a[mid:]):
245 lo = mid + 1
246 else:
247 hi = mid
248 return lo

Callers 2

_storeMethod · 0.85

Calls

no outgoing calls

Tested by 1