Last change
on this file since 1284 was 243, checked in by wouter, 4 years ago |
fix type issue in immutablelist
|
File size:
1.1 KB
|
Line | |
---|
1 | from abc import ABC, abstractmethod
|
---|
2 | from decimal import Decimal
|
---|
3 | from typing import Generic, TypeVar
|
---|
4 |
|
---|
5 |
|
---|
6 | E = TypeVar('E')
|
---|
7 | class 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 < 0 || index >= 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.