SetMut
Bases: PyoMutableSet[T], ArgsWrapper[T]
flowchart TD
pyochain.core._set.SetMut[SetMut]
pyochain.abc._mutable_set.PyoMutableSet[PyoMutableSet]
pyochain.abc._set.PyoSet[PyoSet]
pyochain.abc._collection.PyoCollection[PyoCollection]
pyochain.abc._iterable.PyoIterable[PyoIterable]
pyochain.abc._collection.PyoContainer[PyoContainer]
pyochain.abc._collection.PyoSized[PyoSized]
pyochain.abc._mixins.Checkable[Checkable]
pyochain.abc._mixins.Fluent[Fluent]
pyochain.abc._mixins.Pipe[Pipe]
pyochain.abc._mixins.Tap[Tap]
pyochain.abc.constructors.ArgsWrapper[ArgsWrapper]
pyochain.abc.constructors.FromArgs[FromArgs]
pyochain.abc.constructors.FromIter[FromIter]
pyochain.abc.constructors.Wrapper[Wrapper]
pyochain.abc._mutable_set.PyoMutableSet --> pyochain.core._set.SetMut
pyochain.abc._set.PyoSet --> pyochain.abc._mutable_set.PyoMutableSet
pyochain.abc._collection.PyoCollection --> pyochain.abc._set.PyoSet
pyochain.abc._iterable.PyoIterable --> pyochain.abc._collection.PyoCollection
pyochain.abc._mixins.Checkable --> pyochain.abc._iterable.PyoIterable
pyochain.abc._mixins.Fluent --> pyochain.abc._iterable.PyoIterable
pyochain.abc._mixins.Pipe --> pyochain.abc._mixins.Fluent
pyochain.abc._mixins.Tap --> pyochain.abc._mixins.Fluent
pyochain.abc._collection.PyoContainer --> pyochain.abc._collection.PyoCollection
pyochain.abc._mixins.Checkable --> pyochain.abc._collection.PyoContainer
pyochain.abc._collection.PyoSized --> pyochain.abc._collection.PyoCollection
pyochain.abc._mixins.Checkable --> pyochain.abc._collection.PyoSized
pyochain.abc.constructors.ArgsWrapper --> pyochain.core._set.SetMut
pyochain.abc.constructors.FromArgs --> pyochain.abc.constructors.ArgsWrapper
pyochain.abc.constructors.FromIter --> pyochain.abc.constructors.FromArgs
pyochain.abc.constructors.Wrapper --> pyochain.abc.constructors.ArgsWrapper
click pyochain.core._set.SetMut href "" "pyochain.core._set.SetMut"
click pyochain.abc._mutable_set.PyoMutableSet href "" "pyochain.abc._mutable_set.PyoMutableSet"
click pyochain.abc._set.PyoSet href "" "pyochain.abc._set.PyoSet"
click pyochain.abc._collection.PyoCollection href "" "pyochain.abc._collection.PyoCollection"
click pyochain.abc._iterable.PyoIterable href "" "pyochain.abc._iterable.PyoIterable"
click pyochain.abc._collection.PyoContainer href "" "pyochain.abc._collection.PyoContainer"
click pyochain.abc._collection.PyoSized href "" "pyochain.abc._collection.PyoSized"
click pyochain.abc._mixins.Checkable href "" "pyochain.abc._mixins.Checkable"
click pyochain.abc._mixins.Fluent href "" "pyochain.abc._mixins.Fluent"
click pyochain.abc._mixins.Pipe href "" "pyochain.abc._mixins.Pipe"
click pyochain.abc._mixins.Tap href "" "pyochain.abc._mixins.Tap"
click pyochain.abc.constructors.ArgsWrapper href "" "pyochain.abc.constructors.ArgsWrapper"
click pyochain.abc.constructors.FromArgs href "" "pyochain.abc.constructors.FromArgs"
click pyochain.abc.constructors.FromIter href "" "pyochain.abc.constructors.FromIter"
click pyochain.abc.constructors.Wrapper href "" "pyochain.abc.constructors.Wrapper"
A mutable, unordered collection of unique elements.
Unlike Set which is immutable, SetMut allows in-place modification of elements.
Implement the collections::abc::MutableSet interface, so elements can be modified in place, and passed to any function/object expecting a standard mutable set.
Underlying data structure is a set.
Source code in pyochain/core/_set.pyi
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | |
__new__(data=(), /, *more)
__new__(data: Iterable[T]) -> Self
__new__(data: T, *more: T) -> Self
__new__() -> Self
Create a new SetMut instance.
If no arguments are provided, an empty SetMut is created.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Iterable[T] | T
|
Initial elements to populate the set with. Defaults to |
()
|
*more
|
T
|
Additional elements to add to the set. |
()
|
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
A new |
Example
from pyochain import SetMut
data = (0, 1, 2, 3)
# Create a `SetMut` from an iterable
assert SetMut(data) == SetMut(range(0, 4)) == set(data)
# Create a `SetMut` from a single, non-iterable element
assert SetMut(1) == SetMut((1,)) == SetMut([1]) == set([1])
# Create a `SetMut` from multiple elements
assert SetMut(0, 1, 2, 3) == SetMut(data)
# Create an empty `SetMut`
assert SetMut() == SetMut([]) == SetMut(()) == set()
assert repr(SetMut()) == "SetMut()"
Source code in pyochain/core/_set.pyi
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
__and__(value)
Return self&value.
Source code in pyochain/core/_set.pyi
341 342 343 344 | |
__iand__(value)
Return self&=value.
Source code in pyochain/core/_set.pyi
346 347 348 | |
__or__(value)
Return self|value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[S]
|
The set to perform the union with. |
required |
Returns:
| Type | Description |
|---|---|
SetMut[T | S]
|
SetMut[T | S]: A new |
Example
from pyochain import SetMut
s1 = SetMut(1, 2, 3)
s2 = SetMut(3, 4, 5)
s3 = s1 | s2
assert s3 == SetMut(1, 2, 3, 4, 5)
Source code in pyochain/core/_set.pyi
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
__ior__(value)
Return self|=value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[T]
|
The set to perform the union with. |
required |
Returns:
| Type | Description |
|---|---|
SetMut[T]
|
SetMut[T]: The current instance after performing the union operation. |
Example
from pyochain import SetMut
s1 = SetMut(1, 2, 3)
s2 = SetMut(3, 4, 5)
s1 |= s2
assert s1 == SetMut(1, 2, 3, 4, 5)
Source code in pyochain/core/_set.pyi
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 | |
__sub__(value)
Return self-value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[object]
|
The set to subtract. |
required |
Returns:
| Type | Description |
|---|---|
SetMut[T]
|
SetMut[T]: A new |
Example
from pyochain import SetMut
s1 = SetMut(1, 2, 3)
s2 = SetMut(2, 3, 4)
s3 = s1 - s2
assert s3 == SetMut(1)
Source code in pyochain/core/_set.pyi
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 | |
__isub__(value)
Return self-=value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[object]
|
The set to subtract. |
required |
Returns:
| Type | Description |
|---|---|
SetMut[T]
|
SetMut[T]: The current instance after performing the subtraction operation. |
Example
from pyochain import SetMut
s1 = SetMut(1, 2, 3)
s2 = SetMut(2, 3, 4)
s1 -= s2
assert s1 == SetMut(1)
Source code in pyochain/core/_set.pyi
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
__xor__(value)
Return self^value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[S]
|
The set to perform the symmetric difference with. |
required |
Returns:
| Type | Description |
|---|---|
SetMut[T | S]
|
SetMut[T | S]: A new |
Example
from pyochain import SetMut
s1 = SetMut(1, 2, 3)
s2 = SetMut(3, 4, 5)
s3 = s1 ^ s2
assert s3 == SetMut(1, 2, 4, 5)
Source code in pyochain/core/_set.pyi
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
__ixor__(value)
Return self^=value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[T]
|
The set to perform the symmetric difference with. |
required |
Returns:
| Type | Description |
|---|---|
SetMut[T]
|
SetMut[T]: The current instance after performing the symmetric difference operation. |
Example
from pyochain import SetMut
s1 = SetMut(1, 2, 3)
s2 = SetMut(3, 4, 5)
s1 ^= s2
assert s1 == SetMut(1, 2, 4, 5)
Source code in pyochain/core/_set.pyi
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | |
__le__(value)
Return self<=value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[object]
|
The set to compare against. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Example
from pyochain import SetMut
s1 = SetMut(1, 2)
s2 = SetMut(1, 2, 3)
assert s1 <= s2
assert not s2 <= s1
Source code in pyochain/core/_set.pyi
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
__lt__(value)
Return self<value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[object]
|
The set to compare against. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Example
from pyochain import SetMut
s1 = SetMut(1, 2)
s2 = SetMut(1, 2, 3)
assert s1 < s2
assert not s2 < s1
Source code in pyochain/core/_set.pyi
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | |
__ge__(value)
Return self>=value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[object]
|
The set to compare against. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Example
from pyochain import SetMut
s1 = SetMut(1, 2, 3)
s2 = SetMut(1, 2)
assert s1 >= s2
assert not s2 >= s1
Source code in pyochain/core/_set.pyi
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
__gt__(value)
Return self>value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Set[object]
|
The set to compare against. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
|
Example
from pyochain import SetMut
s1 = SetMut(1, 2, 3)
s2 = SetMut(1, 2)
assert s1 > s2
assert not s2 > s1
Source code in pyochain/core/_set.pyi
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 | |
add(value)
Add an element to self.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
T
|
The element to add. |
required |
Example
from pyochain import SetMut, Vec
s = SetMut("a", "b")
s.add("c")
assert s.iter().sort() == Vec("a", "b", "c")
Source code in pyochain/core/_set.pyi
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
copy()
Create a shallow copy of the underlying set.
Returns:
| Name | Type | Description |
|---|---|---|
Self |
Self
|
A shallow copy of the underlying |
Example
from pyochain import SetMut
s = SetMut("a", "b")
s_copy = s.copy()
s_copy.add("c")
assert not "c" in s
assert "c" in s_copy
Source code in pyochain/core/_set.pyi
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
discard(value)
Remove an element from self if it is a member.
Unlike SetMut::remove, this method does not raise an exception when an element is missing from the set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
T
|
The element to remove. |
required |
Example
from pyochain import SetMut, Vec
s = SetMut("a", "b", "c")
s.discard("b")
assert s.iter().sort() == Vec("a", "c")
Source code in pyochain/core/_set.pyi
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | |
intersection_update(*s)
Update the set, keeping only elements found in it and all others.
Source code in pyochain/core/_set.pyi
626 627 | |
isdisjoint(s)
Return True if two sets have a null intersection.
Source code in pyochain/core/_set.pyi
629 630 631 | |
remove(element)
Remove an element from a set; it must be a member.
If the element is not a member, raise a KeyError.
Source code in pyochain/core/_set.pyi
637 638 639 640 641 642 | |
symmetric_difference_update(s)
Update the set, keeping only elements found in either set, but not in both.
Source code in pyochain/core/_set.pyi
644 645 | |
update(*s)
Update the set, adding elements from all others.
Source code in pyochain/core/_set.pyi
655 656 | |
difference_update(*s)
Update the set, removing elements found in others.
Source code in pyochain/core/_set.pyi
662 663 | |