A Trie is a key-value store where the keys are of type String
,
and the internal structure is a tree that branches on the bytes of the string.
- leaf: {α : Type} → Option α → Lean.Data.Trie α
- node1: {α : Type} → Option α → UInt8 → Lean.Data.Trie α → Lean.Data.Trie α
- node: {α : Type} → Option α → ByteArray → Array (Lean.Data.Trie α) → Lean.Data.Trie α
Instances For
Insert or update the value at a the given key s
.
Instances For
partial def
Lean.Data.Trie.upsert.insertEmpty
{α : Type}
(s : String)
(f : Option α → α)
(i : Nat)
:
partial def
Lean.Data.Trie.upsert.loop
{α : Type}
(s : String)
(f : Option α → α)
:
Nat → Lean.Data.Trie α → Lean.Data.Trie α
Inserts a value at a the given key s
, overriding an existing value if present.
Instances For
Looks up a value at the given key s
.
Instances For
Returns an Array
of all values in the trie, in no particular order.
Equations
- t.values = (StateT.run (Lean.Data.Trie.values.go t) #[]).snd
Instances For
Returns all values whose key have the given string pre
as a prefix, in no particular order.
Instances For
partial def
Lean.Data.Trie.findPrefix.go
{α : Type}
(pre : String)
(t : Lean.Data.Trie α)
(i : Nat)
:
Array α
def
Lean.Data.Trie.matchPrefix
{α : Type}
(s : String)
(t : Lean.Data.Trie α)
(i : String.Pos)
:
Option α
Find the longest key in the trie that is contained in the given string s
at position i
,
and return the associated value.
Instances For
partial def
Lean.Data.Trie.matchPrefix.loop
{α : Type}
(s : String)
:
Lean.Data.Trie α → Nat → Option α → Option α