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:Decimal) -> 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 @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()) ''' @abstractmethod def size(self) -> Decimal: ''' @return the number of elements in this list. ''' @abstractmethod def __iter__(self) -> E: ''' iterates over the objects in the list '''