latest.ipv8.dht.trie

Module Contents

Classes

Node

This class represents a node within a prefix tree.

Trie

This class represents a prefix tree.

Attributes

NullType

Null

ValueType

latest.ipv8.dht.trie.NullType
latest.ipv8.dht.trie.Null
latest.ipv8.dht.trie.ValueType
class latest.ipv8.dht.trie.Node

Bases: Generic[ValueType]

This class represents a node within a prefix tree.

class latest.ipv8.dht.trie.Trie(alphabet: str)

Bases: Generic[ValueType]

This class represents a prefix tree.

_find(key: str) Node[ValueType] | None

Find the node to serve for the given key.

__getitem__(key: str) ValueType

Get the value belonging to a given key.

__setitem__(key: str, value: ValueType) None

Set the value for the given key.

__delitem__(key: str) None

Remove the given key or raise a KeyError if the key was not found.

itervalues() Iterator[ValueType]

Iterate over all stored values.

values() list[ValueType]

Get all the stored values as a list.

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.

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.

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.

suffixes(key: str) list[str]

Get the known suffixes for the given key.