feat: RBTree.union/diff
This commit is contained in:
parent
fb574af873
commit
bda871da25
1 changed files with 9 additions and 0 deletions
|
|
@ -101,6 +101,15 @@ def subset (t₁ t₂ : RBTree α cmp) : Bool :=
|
|||
def seteq (t₁ t₂ : RBTree α cmp) : Bool :=
|
||||
subset t₁ t₂ && subset t₂ t₁
|
||||
|
||||
def union (t₁ t₂ : RBTree α cmp) : RBTree α cmp :=
|
||||
if t₁.isEmpty then
|
||||
t₂
|
||||
else
|
||||
t₂.fold .insert t₁
|
||||
|
||||
def diff (t₁ t₂ : RBTree α cmp) : RBTree α cmp :=
|
||||
t₂.fold .erase t₁
|
||||
|
||||
end RBTree
|
||||
|
||||
def rbtreeOf {α : Type u} (l : List α) (cmp : α → α → Ordering) : RBTree α cmp :=
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue