MCPcopy Index your code
hub / github.com/python/cpython / _binary_search

Method _binary_search

Lib/idlelib/autocomplete_w.py:78–89  ·  view source on GitHub ↗

Find the first index in self.completions where completions[i] is greater or equal to s, or the last index if there is no such.

(self, s)

Source from the content-addressed store, hash-verified

76 self.start = newstart
77
78 def _binary_search(self, s):
79 """Find the first index in self.completions where completions[i] is
80 greater or equal to s, or the last index if there is no such.
81 """
82 i = 0; j = len(self.completions)
83 while j > i:
84 m = (i + j) // 2
85 if self.completions[m] >= s:
86 j = m
87 else:
88 i = m + 1
89 return min(i, len(self.completions)-1)
90
91 def _complete_string(self, s):
92 """Assuming that s is the prefix of a string in self.completions,

Callers 4

_complete_stringMethod · 0.95
_selection_changedMethod · 0.95
show_windowMethod · 0.95
keypress_eventMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected