Last change
on this file since 233 was 195, checked in by wouter, 4 years ago |
preparing python version of immutablelist
|
File size:
1.0 KB
|
Rev | Line | |
---|
[195] | 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: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 < 0 || index >= 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.