Sets
The galactic.algebras.set
module defines several set classes.
FIFOSet
for creating FIFOSet;IterableSet
which is a mixin class for iterable sets;FIFOSetFactory
for giving the ability to create sets for set operations.
- class FIFOSet(*args: Iterable[galactic.algebras.set._main._T])
The
FIFOSet
is a kind of set that remembers the order of its entries.Examples
>>> from galactic.algebras.set import FIFOSet >>> a = FIFOSet[int]([3, 5, 1, 2, 6, 2]) >>> list(a) [3, 5, 1, 2, 6] >>> list(a | FIFOSet[int]([1, 5, 7 ,8, 9])) [3, 5, 1, 2, 6, 7, 8, 9]
- __init__(*args: Iterable[galactic.algebras.set._main._T]) None
Initialise a
FIFOSet
instance.The initializer can take 0 or 1 argument that should be iterable.
- discard(value: galactic.algebras.set._main._T) None
Discard
value
from the set if it is present.- Parameters:
value (
_T
) – The value to remove.
- isdisjoint(other)
Return True if two sets have a null intersection.
- move_to_end(value: galactic.algebras.set._main._T, last: bool = True) None
Move an existing
value
to either end of aFIFOSet
.The value is moved to the right end if
last
isTrue
(the default) or to the beginning iflast
isFalse
.
- pop(last: bool = False) galactic.algebras.set._main._T
Remove and return an existing value from either end of a
FIFOSet
.
- class FIFOSetFactory(*args, **kwds)
The
FIFOSetFactory
class provides a_from_iterable()
class methods.This method is used by builtin set classes when set operations are executed.
Notes
See https://docs.python.org/fr/3/library/collections.abc.html.
- class IterableSet(*args, **kwds)
The
IterableSet
class implements some basic operations.This allow sub-classes to only implement the
__iter__()
method.- isdisjoint(other)
Return True if two sets have a null intersection.