chore: upstream HashSet.merge (#3357)

This commit is contained in:
Scott Morrison 2024-02-16 12:38:16 +11:00 committed by GitHub
parent 1d9074c524
commit a4e27d3090
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -194,3 +194,11 @@ def insertMany [ForIn Id ρ α] (s : HashSet α) (as : ρ) : HashSet α := Id.ru
for a in as do
s := s.insert a
return s
/--
`O(|t|)` amortized. Merge two `HashSet`s.
-/
@[inline]
def merge {α : Type u} [BEq α] [Hashable α] (s t : HashSet α) : HashSet α :=
t.fold (init := s) fun s a => s.insert a
-- We don't use `insertMany` here because it gives weird universes.