Last change
on this file since 60 was 59, checked in by Wouter Pasman, 3 years ago |
#44 manual commit of first public release, because this will cause the dist directory to move
|
File size:
952 bytes
|
Rev | Line | |
---|
[59] | 1 | from copy import copy
|
---|
| 2 | from decimal import Decimal
|
---|
| 3 | from typing import List
|
---|
| 4 |
|
---|
| 5 | from geniusweb.issuevalue.DiscreteValue import DiscreteValue
|
---|
| 6 | from geniusweb.issuevalue.Value import Value
|
---|
| 7 | from geniusweb.issuevalue.ValueSet import ValueSet
|
---|
| 8 |
|
---|
| 9 |
|
---|
| 10 | class DiscreteValueSet (ValueSet):
|
---|
| 11 |
|
---|
| 12 | def __init__(self, values: List[DiscreteValue]) :
|
---|
| 13 | self._values= copy(values)
|
---|
| 14 |
|
---|
| 15 | def getValues(self) -> List[DiscreteValue]:
|
---|
| 16 | return copy(self._values)
|
---|
| 17 |
|
---|
| 18 | def contains(self, value:Value ) ->bool:
|
---|
| 19 | return value in self._values
|
---|
| 20 |
|
---|
| 21 | def get(self,index:Decimal) -> DiscreteValue :
|
---|
| 22 | return self._values[int(index)]
|
---|
| 23 |
|
---|
| 24 | def size(self) -> Decimal :
|
---|
| 25 | return Decimal(len(self._values))
|
---|
| 26 |
|
---|
| 27 | def __repr__(self):
|
---|
| 28 | # workaround, str(list) seems to call __repro__ isntead of _-str__....
|
---|
| 29 | return "DiscreteValueSet" + repr(self._values)
|
---|
| 30 |
|
---|
| 31 | def __eq__(self, other):
|
---|
| 32 | return isinstance(other, self.__class__) and self._values==other._values
|
---|
| 33 |
|
---|
| 34 | def __hash__(self):
|
---|
| 35 | return hash((tuple(self._values))) |
---|
Note:
See
TracBrowser
for help on using the repository browser.