MCPcopy Create free account
hub / github.com/rthalley/dnspython / insert_element

Method insert_element

dns/btree.py:665–686  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 2

__setitem__Method · 0.80
addMethod · 0.80

Calls 7

_NodeClass · 0.85
maybe_cowMethod · 0.80
is_maximalMethod · 0.80
adoptMethod · 0.80
insert_nonfullMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected