from abc import ABC, abstractmethod from decimal import Decimal from typing import Generic, TypeVar E = TypeVar('E') class ImmutableList(ABC, Generic[E]): ''' Immutable (read-only) list. Implementations are possibly procedural, and can therefore "hold" infinite number of items. @param type of the contained elements ''' @abstractmethod def get(self, index:int) -> E: ''' Returns the element at the specified position in this list. 0 based @param index index of the element to return, 0 is the first element. @return the element at the specified position in this list. Notice that the python int is not limited in size. @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()) ''' @abstractmethod def size(self) -> int: ''' @return the number of elements in this list. ''' @abstractmethod def __iter__(self) -> E: ''' iterates over the objects in the list '''