Insert the element into the BTree. If *in_order* is ``True``, then extra work will be done to make left siblings full, which optimizes storage space when the the elements are inserted in-order or close to it. Returns the previously existing element at the element's
(self, elt: ET, in_order: bool = False)
| 663 | # rest of the standard mapping API. |
| 664 | |
| 665 | def insert_element(self, elt: ET, in_order: bool = False) -> ET | None: |
| 666 | """Insert the element into the BTree. |
| 667 | |
| 668 | If *in_order* is ``True``, then extra work will be done to make left siblings |
| 669 | full, which optimizes storage space when the the elements are inserted in-order |
| 670 | or close to it. |
| 671 | |
| 672 | Returns the previously existing element at the element's key or ``None``. |
| 673 | """ |
| 674 | self._check_mutable_and_park() |
| 675 | cloned = self.root.maybe_cow(self.creator) |
| 676 | if cloned: |
| 677 | self.root = cloned |
| 678 | if self.root.is_maximal(): |
| 679 | old_root = self.root |
| 680 | self.root = _Node(self.t, self.creator, False) |
| 681 | self.root.adopt(*old_root.split()) |
| 682 | oelt = self.root.insert_nonfull(elt, in_order) |
| 683 | if oelt is None: |
| 684 | # We did not replace, so something was added. |
| 685 | self.size += 1 |
| 686 | return oelt |
| 687 | |
| 688 | def get_element(self, key: KT) -> ET | None: |
| 689 | """Get the element matching *key* from the BTree, or return ``None`` if it |
no test coverage detected