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