Return an index to insert `value` in the sorted list. If the `value` is already present, the insertion point will be before (to the left of) any existing values. Similar to the `bisect` module in the standard library. Runtime complexity: `O(log(n))` -- approximate.
(self, value)
| 1164 | |
| 1165 | |
| 1166 | def bisect_left(self, value): |
| 1167 | """Return an index to insert `value` in the sorted list. |
| 1168 | |
| 1169 | If the `value` is already present, the insertion point will be before |
| 1170 | (to the left of) any existing values. |
| 1171 | |
| 1172 | Similar to the `bisect` module in the standard library. |
| 1173 | |
| 1174 | Runtime complexity: `O(log(n))` -- approximate. |
| 1175 | |
| 1176 | >>> sl = SortedList([10, 11, 12, 13, 14]) |
| 1177 | >>> sl.bisect_left(12) |
| 1178 | 2 |
| 1179 | |
| 1180 | :param value: insertion index of value in sorted list |
| 1181 | :return: index |
| 1182 | |
| 1183 | """ |
| 1184 | _maxes = self._maxes |
| 1185 | |
| 1186 | if not _maxes: |
| 1187 | return 0 |
| 1188 | |
| 1189 | pos = bisect_left(_maxes, value) |
| 1190 | |
| 1191 | if pos == len(_maxes): |
| 1192 | return self._len |
| 1193 | |
| 1194 | idx = bisect_left(self._lists[pos], value) |
| 1195 | return self._loc(pos, idx) |
| 1196 | |
| 1197 | |
| 1198 | def bisect_right(self, value): |