source: immutablelistpy/immutablelist/ImmutableList.py@ 211

Last change on this file since 211 was 195, checked in by wouter, 3 years ago

preparing python version of immutablelist

File size: 1.0 KB
Line 
1from abc import ABC, abstractmethod
2from decimal import Decimal
3from typing import Generic, TypeVar
4
5
6E = TypeVar('E')
7class ImmutableList(ABC, Generic[E]):
8 '''
9 Immutable (read-only) list. Implementations are possibly procedural, and can
10 therefore "hold" infinite number of items.
11
12 @param <E> type of the contained elements
13 '''
14 @abstractmethod
15 def get(self, index:Decimal) -> E:
16 '''
17 Returns the element at the specified position in this list. 0 based
18 @param index index of the element to return, 0 is the first element.
19 @return the element at the specified position in this list
20 @throws IndexOutOfBoundsException if the index is out of range
21 (<tt>index &lt; 0 || index &gt;= size()</tt>)
22 '''
23
24 @abstractmethod
25 def size(self) -> Decimal:
26 '''
27 @return the number of elements in this list.
28 '''
29
30 @abstractmethod
31 def __iter__(self) -> E:
32 '''
33 iterates over the objects in the list
34 '''
Note: See TracBrowser for help on using the repository browser.