ordered_set_interface

ソースコード

from titan_pylib.my_class.ordered_set_interface import OrderedSetInterface

view on github

展開済みコード

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

仕様

class OrderedSetInterface(a: Iterable[T])[source]

Bases: ABC, Generic[T]

abstractmethod add(key: T) bool[source]
abstractmethod clear() None[source]
abstractmethod discard(key: T) bool[source]
abstractmethod ge(key: T) T | None[source]
abstractmethod get_max() T | None[source]
abstractmethod get_min() T | None[source]
abstractmethod gt(key: T) T | None[source]
abstractmethod le(key: T) T | None[source]
abstractmethod lt(key: T) T | None[source]
abstractmethod pop_max() T[source]
abstractmethod pop_min() T[source]
abstractmethod remove(key: T) None[source]
abstractmethod tolist() list[T][source]