stl_treemap.insertion_result

Result type for tree insertion operations.

 1"""Result type for tree insertion operations."""
 2
 3from __future__ import annotations
 4
 5
 6class InsertionResult[I]:
 7    """
 8    Reports whether an insert operation was successful.
 9
10    If a node was added or an existing one replaced, an iterator is provided.
11    Otherwise iterator is None.
12    """
13
14    def __init__(self, was_added: bool, was_replaced: bool, iterator: I | None = None) -> None:
15        """
16        Create an insertion result.
17
18        Args:
19            was_added: True when a new value was added to the container.
20            was_replaced: True when a new value replaced an existing value in the container.
21            iterator: Iterator pointing to the newly added or replaced node, or None.
22
23        """
24        self.was_added = was_added  # Boolean flag indicating whether an element was added
25        self.was_replaced = was_replaced  # Boolean flag indicating whether an existing node was updated
26        self.iterator = iterator  # Iterator instance pointing to the newly added node
class InsertionResult(typing.Generic[I]):
 7class InsertionResult[I]:
 8    """
 9    Reports whether an insert operation was successful.
10
11    If a node was added or an existing one replaced, an iterator is provided.
12    Otherwise iterator is None.
13    """
14
15    def __init__(self, was_added: bool, was_replaced: bool, iterator: I | None = None) -> None:
16        """
17        Create an insertion result.
18
19        Args:
20            was_added: True when a new value was added to the container.
21            was_replaced: True when a new value replaced an existing value in the container.
22            iterator: Iterator pointing to the newly added or replaced node, or None.
23
24        """
25        self.was_added = was_added  # Boolean flag indicating whether an element was added
26        self.was_replaced = was_replaced  # Boolean flag indicating whether an existing node was updated
27        self.iterator = iterator  # Iterator instance pointing to the newly added node

Reports whether an insert operation was successful.

If a node was added or an existing one replaced, an iterator is provided. Otherwise iterator is None.

InsertionResult(was_added: bool, was_replaced: bool, iterator: 'I | None' = None)
15    def __init__(self, was_added: bool, was_replaced: bool, iterator: I | None = None) -> None:
16        """
17        Create an insertion result.
18
19        Args:
20            was_added: True when a new value was added to the container.
21            was_replaced: True when a new value replaced an existing value in the container.
22            iterator: Iterator pointing to the newly added or replaced node, or None.
23
24        """
25        self.was_added = was_added  # Boolean flag indicating whether an element was added
26        self.was_replaced = was_replaced  # Boolean flag indicating whether an existing node was updated
27        self.iterator = iterator  # Iterator instance pointing to the newly added node

Create an insertion result.

Args: was_added: True when a new value was added to the container. was_replaced: True when a new value replaced an existing value in the container. iterator: Iterator pointing to the newly added or replaced node, or None.

was_added
was_replaced
iterator