Split sublists with length greater than double the load-factor. Updates the index when the sublist length is less than double the load level. This requires incrementing the nodes in a traversal from the leaf node to the root. For an example traversal see ``SortedList
(self, pos)
| 287 | |
| 288 | |
| 289 | def _expand(self, pos): |
| 290 | """Split sublists with length greater than double the load-factor. |
| 291 | |
| 292 | Updates the index when the sublist length is less than double the load |
| 293 | level. This requires incrementing the nodes in a traversal from the |
| 294 | leaf node to the root. For an example traversal see |
| 295 | ``SortedList._loc``. |
| 296 | |
| 297 | """ |
| 298 | _load = self._load |
| 299 | _lists = self._lists |
| 300 | _index = self._index |
| 301 | |
| 302 | if len(_lists[pos]) > (_load << 1): |
| 303 | _maxes = self._maxes |
| 304 | |
| 305 | _lists_pos = _lists[pos] |
| 306 | half = _lists_pos[_load:] |
| 307 | del _lists_pos[_load:] |
| 308 | _maxes[pos] = _lists_pos[-1] |
| 309 | |
| 310 | _lists.insert(pos + 1, half) |
| 311 | _maxes.insert(pos + 1, half[-1]) |
| 312 | |
| 313 | del _index[:] |
| 314 | else: |
| 315 | if _index: |
| 316 | child = self._offset + pos |
| 317 | while child: |
| 318 | _index[child] += 1 |
| 319 | child = (child - 1) >> 1 |
| 320 | _index[0] += 1 |
| 321 | |
| 322 | |
| 323 | def update(self, iterable): |