source: utilitiespy/tudelft/utilities/immutablelist/ImmutableList.py@ 1357

Last change on this file since 1357 was 243, checked in by wouter, 3 years ago

fix type issue in immutablelist

File size: 1.1 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:int) -> 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 Notice that the python int is not limited in size.
21 @throws IndexOutOfBoundsException if the index is out of range
22 (<tt>index &lt; 0 || index &gt;= size()</tt>)
23 '''
24
25 @abstractmethod
26 def size(self) -> int:
27 '''
28 @return the number of elements in this list.
29 '''
30
31 @abstractmethod
32 def __iter__(self) -> E:
33 '''
34 iterates over the objects in the list
35 '''
Note: See TracBrowser for help on using the repository browser.