Collections
The galactic.algebras.collection
modules.
It defines some protocols for collections:
- class ExtensibleCollection(*args, **kwargs)
Bases:
Collection
[_E
],Protocol
It represents extensible collections.
- abstract extend(iterable)
Extend the collection by adding the elements of the iterable.
Other elements can be added by the method in order to maintain the algebraic consistency of the structures involved.
- Parameters:
- Raises:
- Return type:
- class MutableCollection(*args, **kwargs)
Bases:
ExtensibleCollection
[_E
],Protocol
It represents mutable collections.
- abstract add(value)
Add a value to the collection.
- Parameters:
value (
TypeVar
(_E
)) – The value to add.- Raises:
- Return type:
- abstract remove(value)
Remove a value from the collection.
This method can raise a KeyError if the value does not belong to the collection.
- Parameters:
value (
TypeVar
(_E
)) – The value to remove.- Raises:
- Return type:
- abstract discard(value)
Discard a value from the collection.
- Parameters:
value (
TypeVar
(_E
)) – The value to discard.- Raises:
- Return type:
- abstract pop()
Remove and return an arbitrary element from the collection.
This method can raise a KeyError if the collection is empty.
- Returns:
The value removed.
- Return type:
_E
- Raises:
- abstract clear()
Clear the collection.
- Raises:
- Return type:
- abstract extend(iterable)
Extend the collection by adding the elements of the iterable.
Other elements can be added by the method in order to maintain the algebraic consistency of the structures involved.
- Parameters:
- Raises:
- Return type: