Return an index to insert `value` in the sorted list. Similar to `bisect_left`, but if `value` is already present, the insertion point will be after (to the right of) any existing values. Similar to the `bisect` module in the standard library. Runtime complexity: `
(self, value)
| 1196 | |
| 1197 | |
| 1198 | def bisect_right(self, value): |
| 1199 | """Return an index to insert `value` in the sorted list. |
| 1200 | |
| 1201 | Similar to `bisect_left`, but if `value` is already present, the |
| 1202 | insertion point will be after (to the right of) any existing values. |
| 1203 | |
| 1204 | Similar to the `bisect` module in the standard library. |
| 1205 | |
| 1206 | Runtime complexity: `O(log(n))` -- approximate. |
| 1207 | |
| 1208 | >>> sl = SortedList([10, 11, 12, 13, 14]) |
| 1209 | >>> sl.bisect_right(12) |
| 1210 | 3 |
| 1211 | |
| 1212 | :param value: insertion index of value in sorted list |
| 1213 | :return: index |
| 1214 | |
| 1215 | """ |
| 1216 | _maxes = self._maxes |
| 1217 | |
| 1218 | if not _maxes: |
| 1219 | return 0 |
| 1220 | |
| 1221 | pos = bisect_right(_maxes, value) |
| 1222 | |
| 1223 | if pos == len(_maxes): |
| 1224 | return self._len |
| 1225 | |
| 1226 | idx = bisect_right(self._lists[pos], value) |
| 1227 | return self._loc(pos, idx) |
| 1228 | |
| 1229 | bisect = bisect_right |
| 1230 | _bisect_right = bisect_right |