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 α → Trie α
- node1 {α : Type} : Option α → UInt8 → Trie α → Trie α
- node {α : Type} : Option α → ByteArray → Array (Trie α) → Trie α
Instances For
Equations
- Lean.Data.Trie.instEmptyCollection = { emptyCollection := Lean.Data.Trie.empty }
Equations
- Lean.Data.Trie.instInhabited = { default := Lean.Data.Trie.empty }
Insert or update the value at a the given key s
.
Equations
- t.upsert s f = Lean.Data.Trie.upsert.loop s f 0 t
Instances For
Looks up a value at the given key s
.
Equations
- t.find? 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
- 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.
Equations
- t.findPrefix pre = Lean.Data.Trie.findPrefix.go pre t 0
Instances For
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
Equations
- Lean.Data.Trie.instToString = { toString := fun (t : Lean.Data.Trie α) => (flip Std.Format.joinSep Std.Format.line (Lean.Data.Trie.toStringAux✝ t)).pretty }