- 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 α
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.
Instances For
Equations
- Lean.Data.Trie.instEmptyCollectionTrie = { emptyCollection := Lean.Data.Trie.empty }
Equations
- Lean.Data.Trie.instInhabitedTrie = { default := Lean.Data.Trie.empty }
Insert or update the value at a the given key s
.
Equations
- Lean.Data.Trie.upsert t s f = Lean.Data.Trie.upsert.loop s f 0 t
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.
Equations
- Lean.Data.Trie.insert t s val = Lean.Data.Trie.upsert t s fun x => val
Instances For
Looks up a value at the given key s
.
Equations
- Lean.Data.Trie.find? t s = Lean.Data.Trie.find?.loop s 0 t
Instances For
Returns an Array
of all values in the trie, in no particular order.
Equations
- Lean.Data.Trie.values t = (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.
Equations
- Lean.Data.Trie.findPrefix t pre = Lean.Data.Trie.findPrefix.go pre t 0
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.
Equations
- Lean.Data.Trie.matchPrefix s t i = Lean.Data.Trie.matchPrefix.loop s t i.byteIdx none
Instances For
partial def
Lean.Data.Trie.matchPrefix.loop
{α : Type}
(s : String)
:
Lean.Data.Trie α → Nat → Option α → Option α
Equations
- Lean.Data.Trie.instToStringTrie = { toString := fun t => Lean.Format.pretty (flip Lean.Format.joinSep Lean.Format.line (Lean.Data.Trie.toStringAux t)) }