Skip to content

Commit

Permalink
chore(RBSet): consolidate API from mathlib (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-em authored Jun 12, 2024
1 parent 17987b0 commit f96a344
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Batteries/Data/RBMap/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,16 @@ instance [Repr α] : Repr (RBSet α cmp) where
/-- `O(log n)`. Insert element `v` into the tree. -/
@[inline] def insert (t : RBSet α cmp) (v : α) : RBSet α cmp := ⟨t.1.insert cmp v, t.2.insert⟩

/--
Insert all elements from a collection into a `RBSet α cmp`.
-/
def insertMany [ForIn Id ρ α] (s : RBSet α cmp) (as : ρ) :
RBSet α cmp := Id.run do
let mut s := s
for a in as do
s := s.insert a
return s

/--
`O(log n)`. Remove an element from the tree using a cut function.
The `cut` function is used to locate an element in the tree:
Expand Down

0 comments on commit f96a344

Please sign in to comment.