Python implementation of a polymorphic list
View on PyPI / Documentation / GitHub Source Code
A polymorphic list is a data abstraction similar to LinkedLists where objects of two classes, NonEmptyList
, and EmptyList
, are employed to cleanly handle edge cases where a LinkedList would be null
. In a LinkedList, the last node's next
reference is null
; however, for a PolymorphicList, the last node's next
reference is an EmptyList
, allowing the EmptyList object to override methods defined in a PolymorphicList.
This means that every method is overridden to have a version for a NonEmptyList and for an EmptyList.
pip install py-polymorphic-list
Or install with pip3
, accordingly.
Check out the documentation for full details on usage.