📘 Collections#
In this tutorial, we will explore the various collection types available in the GALACTIC framework. Collections are fundamental data structures that allow us to store and manipulate groups of elements.
We will cover the following collection types from the
galactic.algebras.collection.core module:
ExtensibleCollectionis a protocol for collections that can be extended with new elements. It defines a method for adding elements to the collection. The mechanism for adding elements is left to the specific implementation of the collection (i.e. other elements can be added to preserve algebraic properties). Theextend()method is provided to add multiple elements at once.MutableCollectionis a protocol for collections that can be modified. It extends theExtensibleCollectionprotocol and adds methods for removing elements from the collection:add()method to add a specific element to the collectionremove()method to remove a specific element from the collectiondiscard()method to remove a specific element without raising an error if the element is not presentpop()method to remove and return an arbitrary element from the collectionclear()method to remove all elements from the collection