iadd
This commit is contained in:
@@ -56,16 +56,26 @@ class DAGSet(MutableSet[T]):
|
||||
|
||||
# --- in-place operator support ---
|
||||
|
||||
# def __ior__(self, other: Iterable[T]) -> DAGSet[T]:
|
||||
# # a |= b => add everything in other
|
||||
# return self
|
||||
|
||||
# def __iadd__(self, other: Iterable[T]) -> DAGSet[T]:
|
||||
# # a += b => update/extend
|
||||
# return self
|
||||
def __iadd__(self, other: Iterable[T]) -> DAGSet[T]:
|
||||
# a += b => update/extend
|
||||
match other:
|
||||
case set():
|
||||
self |= other
|
||||
case str():
|
||||
self |= {other}
|
||||
case Iterable():
|
||||
self |= set(other)
|
||||
case _:
|
||||
self |= {other}
|
||||
return self
|
||||
|
||||
# def __isub__(self, other: Iterable[T]) -> DAGSet[T]:
|
||||
# # a -= b => remove those in other
|
||||
# match other:
|
||||
# case set():
|
||||
# self -= other
|
||||
# case _:
|
||||
# self -= set(other)
|
||||
# return self
|
||||
|
||||
# def __iand__(self, other: Iterable[T]) -> DAGSet[T]:
|
||||
|
||||
Reference in New Issue
Block a user