Red-Black Dictionary #
Defines an insertion-ordered key-value mapping backed by an red-black tree.
Implemented via a key-index Std.TreeMap into an Array of key-value pairs.
An insertion-ordered key-value mapping backed by a red-black tree.
- indices : Std.TreeMap α Nat cmp
Instances For
@[instance_reducible]
instance Lake.Toml.instInhabitedRBDict {a✝ : Type u_1} {a✝¹ : Type u_2} {a✝² : a✝ → a✝ → Ordering} :
Equations
@[reducible, inline]
Equations
Instances For
@[instance_reducible]
instance Lake.Toml.RBDict.instEmptyCollection {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} :
EmptyCollection (RBDict α β cmp)
Equations
- Lake.Toml.RBDict.instEmptyCollection = { emptyCollection := Lake.Toml.RBDict.empty }
def Lake.Toml.RBDict.mkEmpty {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (capacity : Nat) :
RBDict α β cmp
Equations
- Lake.Toml.RBDict.mkEmpty capacity = { items := Array.mkEmpty capacity, indices := ∅ }
Instances For
def Lake.Toml.RBDict.findEntry? {α β : Type} {cmp : α → α → Ordering} (k : α) (t : RBDict α β cmp) :
Equations
- Lake.Toml.RBDict.findEntry? k t = do let __do_lift ← Lake.Toml.RBDict.findIdx? k t pure t.items[__do_lift]
Instances For
@[inline]
def Lake.Toml.RBDict.find? {α β : Type} {cmp : α → α → Ordering} (k : α) (t : RBDict α β cmp) :
Option β
Equations
- Lake.Toml.RBDict.find? k t = do let __do_lift ← Lake.Toml.RBDict.findEntry? k t pure __do_lift.snd
Instances For
@[macro_inline]
def Lake.Toml.RBDict.insertIf {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (p : Bool) (k : α) (v : β) (t : RBDict α β cmp) :
RBDict α β cmp
Inserts the value into the dictionary if p is true.
Equations
- Lake.Toml.RBDict.insertIf p k v t = if p = true then Lake.Toml.RBDict.insert k v t else t
Instances For
@[macro_inline]
def Lake.Toml.RBDict.insertUnless {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (p : Bool) (k : α) (v : β) (t : RBDict α β cmp) :
RBDict α β cmp
Inserts the value into the dictionary if p is false.
Equations
- Lake.Toml.RBDict.insertUnless p k v t = if p = true then t else Lake.Toml.RBDict.insert k v t
Instances For
@[macro_inline]
def Lake.Toml.RBDict.insertSome {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (k : α) (v? : Option β) (t : RBDict α β cmp) :
RBDict α β cmp
Insert the value into the dictionary if it is not none.
Equations
- Lake.Toml.RBDict.insertSome k (some v) t = Lake.Toml.RBDict.insert k v t
- Lake.Toml.RBDict.insertSome k v? t = t
Instances For
def Lake.Toml.RBDict.appendArray {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} (self : RBDict α β cmp) (other : Array (α × β)) :
RBDict α β cmp
Equations
- self.appendArray other = Array.foldl (fun (t : Lake.Toml.RBDict α β cmp) (x : α × β) => match x with | (k, v) => Lake.Toml.RBDict.insert k v t) self other
Instances For
@[instance_reducible]
instance Lake.Toml.RBDict.instHAppendArrayProd {α : Type u_1} {β : Type u_2} {cmp : α → α → Ordering} :
Equations
@[instance_reducible]
Equations
- Lake.Toml.RBDict.instAppend = { append := Lake.Toml.RBDict.append }
@[inline]
def Lake.Toml.RBDict.foldM {m : Type u_1 → Type u_2} {σ : Type u_1} {α : Type u_3} {β : Type u_4} {cmp : α → α → Ordering} [Monad m] (f : σ → α → β → m σ) (init : σ) (t : RBDict α β cmp) :
m σ
Equations
- Lake.Toml.RBDict.foldM f init t = Array.foldlM (fun (s : σ) (x : α × β) => match x with | (k, v) => f s k v) init t.items
Instances For
@[inline]
def Lake.Toml.RBDict.fold {σ : Type u_1} {α : Type u_2} {β : Type u_3} {cmp : α → α → Ordering} (f : σ → α → β → σ) (init : σ) (t : RBDict α β cmp) :
σ
Equations
- Lake.Toml.RBDict.fold f init t = (Lake.Toml.RBDict.foldM f init t).run