# =============================================================================
# TrieDict
# =============================================================================
#
# A simple Python implementation of a (prefix, value) Trie.
#
from typing import TypeVar, Generic, Union, Optional, Iterator, Tuple

Value = TypeVar("Value")
DefaultValue = TypeVar("DefaultValue")

class TrieDict(Generic[Value]):
    def __len__(self) -> int: ...
    def __setitem__(self, prefix: str, value: Value) -> None: ...
    def get(
        self, prefix: str, default: DefaultValue = ...
    ) -> Union[Value, DefaultValue]: ...
    def __getitem__(self, prefix: str) -> Value: ...
    def longest_matching_prefix_value(self, prefix: str) -> Optional[Value]: ...
    def items(self) -> Iterator[Tuple[str, Value]]: ...
    def prefixes(self) -> Iterator[str]: ...
    def values(self) -> Iterator[Value]: ...
    def __iter__(self) -> Iterator[Tuple[str, Value]]: ...
    def set_and_prune_if_shorter(self, prefix: str, value: Value) -> None: ...
