@[specialize #[]]
def Std.HashMap.mergeWithM {m : Type (max u_1 u_2) → Type u_3} {α : Type u_2} {β : Type (max u_1 u_2)} [BEq α] [Hashable α] [Monad m] (f : α → β → β → m β) (self other : HashMap α β) :
m (HashMap α β)
O(|other|) amortized. Merge two HashMaps.
The values of keys which appear in both maps are combined using the monadic function f.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[inline]
def Std.HashMap.mergeWith {α : Type u_1} [BEq α] [Hashable α] {β : Type u_2} (f : α → β → β → β) (self other : HashMap α β) :
HashMap α β
O(|other|) amortized. Merge two HashMaps.
The values of keys which appear in both maps are combined using f.
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[inline]
def Std.HashMap.findEntry? {α : Type u_1} {β : Type u_2} [BEq α] [Hashable α] (m : HashMap α β) (k : α) :
Given a key a, returns a key-value pair in the map whose key compares equal to a.
Note that the returned key may not be identical to the input, if == ignores some part
of the value.
def hashMap := ofList [("one", 1), ("two", 2)]
hashMap.findEntry? "one" = some ("one", 1)
hashMap.findEntry? "three" = none
Instances For
def Std.HashMap.ofListWith {α : Type u_1} {β : Type u_2} [BEq α] [Hashable α] (l : List (α × β)) (f : β → β → β) :
HashMap α β
Variant of ofList which accepts a function that combines values of duplicated keys.
ofListWith [("one", 1), ("one", 2)] (fun v₁ v₂ => v₁ + v₂) = {"one" => 3}
Equations
- One or more equations did not get rendered due to their size.