pathex.adts.containers.onion_collection module

class EmptyOnionCollection(*init_args, **init_kwargs)[source]

Bases: pathex.adts.containers.onion_collection.OnionCollection[pathex.adts.containers.onion_collection._E]

The instance of this class is an empty collection that can be used to construct new NonemptyOnionCollection objects.

class NonemptyOnionCollection(parent: OnionCollection[pathex.adts.containers.onion_collection._E], last: pathex.adts.containers.onion_collection._E)[source]

Bases: pathex.adts.containers.onion_collection.OnionCollection[pathex.adts.containers.onion_collection._E]

This class represents an immutable collection that can be extended by recursively constructing new collections of this type.

>>> c = NonemptyOnionCollection(EmptyOnionCollection(), 3)
>>> assert list(c) == [3]
>>> l = [1, 2, 3, 4]
>>> c = from_iterable(l)
>>> assert list(c) == l
>>> assert 3 in c
>>> assert '3' not in c
>>> s = {c}
>>> c1 = from_iterable(l)
>>> assert c == c1
>>> assert len(c) == len(c1) == len(l)
>>> assert c1 in s
>>> assert 4 not in EmptyOnionCollection()
>>> assert list(EmptyOnionCollection()) == []
last: pathex.adts.containers.onion_collection._E
parent: OnionCollection[pathex.adts.containers.onion_collection._E]
class OnionCollection[source]

Bases: collections.abc.Collection, collections.abc.Reversible, Generic[pathex.adts.containers.onion_collection._E]

Abstract base class for collections thar are immutable, recursive, hashable, and reversible.