Red-Black Dictionary #
Defines an insertion-ordered key-value mapping backed by an red-black tree.
Implemented via a key-index RBMap
into an Array
of key-value pairs.
- indices : Lean.RBMap α Nat cmp
Instances For
instance
Lake.Toml.instInhabitedRBDict
{a✝ : Type u_1}
{a✝¹ : Type u_2}
{a✝² : a✝ → a✝ → Ordering}
:
Inhabited (Lake.Toml.RBDict a✝ a✝¹ a✝²)
Equations
- Lake.Toml.instInhabitedRBDict = { default := { items := default, indices := default } }
@[reducible, inline]
Equations
Instances For
def
Lake.Toml.RBDict.empty
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
:
Lake.Toml.RBDict α β cmp
Instances For
instance
Lake.Toml.RBDict.instEmptyCollection
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
:
EmptyCollection (Lake.Toml.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)
:
Lake.Toml.RBDict α β cmp
Equations
- Lake.Toml.RBDict.mkEmpty capacity = { items := Array.mkEmpty capacity, indices := ∅ }
Instances For
def
Lake.Toml.RBDict.ofArray
{α : Type (max u_1 u_2)}
{β : Type u_2}
{cmp : α → α → Ordering}
(items : Array (α × β))
:
Lake.Toml.RBDict α β cmp
Equations
- One or more equations did not get rendered due to their size.
Instances For
instance
Lake.Toml.RBDict.instBEqOfProd
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
[BEq (α × β)]
:
BEq (Lake.Toml.RBDict α β cmp)
Equations
- Lake.Toml.RBDict.instBEqOfProd = { beq := Lake.Toml.RBDict.beq }
@[reducible, inline]
abbrev
Lake.Toml.RBDict.size
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(t : Lake.Toml.RBDict α β cmp)
:
Equations
- t.size = t.items.size
Instances For
@[reducible, inline]
abbrev
Lake.Toml.RBDict.isEmpty
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(t : Lake.Toml.RBDict α β cmp)
:
Equations
- t.isEmpty = t.items.isEmpty
Instances For
def
Lake.Toml.RBDict.keys
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(t : Lake.Toml.RBDict α β cmp)
:
Array α
Instances For
def
Lake.Toml.RBDict.values
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(t : Lake.Toml.RBDict α β cmp)
:
Array β
Instances For
def
Lake.Toml.RBDict.contains
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(k : α)
(t : Lake.Toml.RBDict α β cmp)
:
Equations
- Lake.Toml.RBDict.contains k t = t.indices.contains k
Instances For
def
Lake.Toml.RBDict.findIdx?
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(k : α)
(t : Lake.Toml.RBDict α β cmp)
:
Equations
- Lake.Toml.RBDict.findIdx? k t = do let i ← t.indices.find? k if h : i < t.items.size then some ⟨i, h⟩ else none
Instances For
def
Lake.Toml.RBDict.findEntry?
{α β : Type}
{cmp : α → α → Ordering}
(k : α)
(t : Lake.Toml.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 : Lake.Toml.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
def
Lake.Toml.RBDict.push
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(k : α)
(v : β)
(t : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.RBDict α β cmp
Equations
- Lake.Toml.RBDict.push k v t = { items := t.items.push (k, v), indices := t.indices.insert k t.items.size }
Instances For
@[specialize #[]]
def
Lake.Toml.RBDict.alter
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(k : α)
(f : Option β → β)
(t : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.RBDict α β cmp
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Lake.Toml.RBDict.insert
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(k : α)
(v : β)
(t : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.RBDict α β cmp
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[macro_inline]
def
Lake.Toml.RBDict.insertIf
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(p : Bool)
(k : α)
(v : β)
(t : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.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 : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.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 : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.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 : Lake.Toml.RBDict α β cmp)
(other : Array (α × β))
:
Lake.Toml.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
Lake.Toml.RBDict.instHAppendArrayProd
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
:
HAppend (Lake.Toml.RBDict α β cmp) (Array (α × β)) (Lake.Toml.RBDict α β cmp)
Equations
- Lake.Toml.RBDict.instHAppendArrayProd = { hAppend := Lake.Toml.RBDict.appendArray }
@[inline]
def
Lake.Toml.RBDict.append
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(self other : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.RBDict α β cmp
Equations
- self.append other = self.appendArray other.items
Instances For
instance
Lake.Toml.RBDict.instAppend
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
:
Append (Lake.Toml.RBDict α β cmp)
Equations
- Lake.Toml.RBDict.instAppend = { append := Lake.Toml.RBDict.append }
@[inline]
def
Lake.Toml.RBDict.map
{α : Type u_1}
{β : Type u_2}
{γ : Type u_3}
{cmp : α → α → Ordering}
(f : α → β → γ)
(t : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.RBDict α γ cmp
Equations
- Lake.Toml.RBDict.map f t = { items := Array.map (fun (x : α × β) => match x with | (k, v) => (k, f k v)) t.items, indices := t.indices }
Instances For
@[inline]
def
Lake.Toml.RBDict.filter
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
(p : α → β → Bool)
(t : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.RBDict α β cmp
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[inline]
def
Lake.Toml.RBDict.filterMap
{α : Type u_1}
{β : Type u_2}
{γ : Type u_3}
{cmp : α → α → Ordering}
(f : α → β → Option γ)
(t : Lake.Toml.RBDict α β cmp)
:
Lake.Toml.RBDict α γ cmp
Equations
- One or more equations did not get rendered due to their size.