Source code for titan_pylib.my_class.ordered_multiset_interface
1from titan_pylib.my_class.supports_less_than import SupportsLessThan
2from abc import ABC, abstractmethod
3from typing import Iterable, Optional, Iterator, TypeVar, Generic
4
5T = TypeVar("T", bound=SupportsLessThan)
6
7
[docs]
8class OrderedMultisetInterface(ABC, Generic[T]):
9
10 @abstractmethod
11 def __init__(self, a: Iterable[T]) -> None:
12 raise NotImplementedError
13
[docs]
14 @abstractmethod
15 def add(self, key: T, cnt: int) -> None:
16 raise NotImplementedError
17
[docs]
18 @abstractmethod
19 def discard(self, key: T, cnt: int) -> bool:
20 raise NotImplementedError
21
[docs]
22 @abstractmethod
23 def discard_all(self, key: T) -> bool:
24 raise NotImplementedError
25
[docs]
26 @abstractmethod
27 def count(self, key: T) -> int:
28 raise NotImplementedError
29
[docs]
30 @abstractmethod
31 def remove(self, key: T, cnt: int) -> None:
32 raise NotImplementedError
33
[docs]
34 @abstractmethod
35 def le(self, key: T) -> Optional[T]:
36 raise NotImplementedError
37
[docs]
38 @abstractmethod
39 def lt(self, key: T) -> Optional[T]:
40 raise NotImplementedError
41
[docs]
42 @abstractmethod
43 def ge(self, key: T) -> Optional[T]:
44 raise NotImplementedError
45
[docs]
46 @abstractmethod
47 def gt(self, key: T) -> Optional[T]:
48 raise NotImplementedError
49
[docs]
50 @abstractmethod
51 def get_max(self) -> Optional[T]:
52 raise NotImplementedError
53
[docs]
54 @abstractmethod
55 def get_min(self) -> Optional[T]:
56 raise NotImplementedError
57
[docs]
58 @abstractmethod
59 def pop_max(self) -> T:
60 raise NotImplementedError
61
[docs]
62 @abstractmethod
63 def pop_min(self) -> T:
64 raise NotImplementedError
65
[docs]
66 @abstractmethod
67 def clear(self) -> None:
68 raise NotImplementedError
69
[docs]
70 @abstractmethod
71 def tolist(self) -> list[T]:
72 raise NotImplementedError
73
74 @abstractmethod
75 def __iter__(self) -> Iterator:
76 raise NotImplementedError
77
78 @abstractmethod
79 def __next__(self) -> T:
80 raise NotImplementedError
81
82 @abstractmethod
83 def __contains__(self, key: T) -> bool:
84 raise NotImplementedError
85
86 @abstractmethod
87 def __len__(self) -> int:
88 raise NotImplementedError
89
90 @abstractmethod
91 def __bool__(self) -> bool:
92 raise NotImplementedError
93
94 @abstractmethod
95 def __str__(self) -> str:
96 raise NotImplementedError
97
98 @abstractmethod
99 def __repr__(self) -> str:
100 raise NotImplementedError