3.0.ipv8.dht.trie ================= .. py:module:: 3.0.ipv8.dht.trie Attributes ---------- .. autoapisummary:: 3.0.ipv8.dht.trie.NullType 3.0.ipv8.dht.trie.Null 3.0.ipv8.dht.trie.ValueType Classes ------- .. autoapisummary:: 3.0.ipv8.dht.trie.Node 3.0.ipv8.dht.trie.Trie Module Contents --------------- .. py:data:: NullType .. py:data:: Null .. py:data:: ValueType .. py:class:: Node Bases: :py:obj:`Generic`\ [\ :py:obj:`ValueType`\ ] This class represents a node within a prefix tree. .. py:attribute:: value :type: ValueType | None :value: None .. py:attribute:: children :type: dict[str, Node] .. py:class:: Trie(alphabet: str) Bases: :py:obj:`Generic`\ [\ :py:obj:`ValueType`\ ] This class represents a prefix tree. .. py:attribute:: alphabet .. py:attribute:: root .. py:method:: _find(key: str) -> Node[ValueType] | None Find the node to serve for the given key. .. py:method:: __getitem__(key: str) -> ValueType Get the value belonging to a given key. .. py:method:: __setitem__(key: str, value: ValueType) -> None Set the value for the given key. .. py:method:: __delitem__(key: str) -> None Remove the given key or raise a KeyError if the key was not found. .. py:method:: itervalues() -> collections.abc.Iterator[ValueType] Iterate over all stored values. .. py:method:: values() -> list[ValueType] Get all the stored values as a list. .. py:method:: longest_prefix_item(key: str, default: tuple[str, ValueType] | NullType = Null) -> tuple[str, ValueType] Get longest matching prefix, for the given key, and its value. Raises a KeyError if no node is found at all. .. py:method:: longest_prefix(key: str, default: str | NullType = Null) -> str Get longest matching prefix, for the given key. Raises a KeyError if no node is found at all. .. py:method:: longest_prefix_value(key: str, default: ValueType | NullType = Null) -> ValueType Get the value of the longest matching prefix, for the given key. Raises a KeyError if no node is found at all. .. py:method:: suffixes(key: str) -> list[str] Get the known suffixes for the given key.