Source code for titan_pylib.my_class.ordered_set_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 OrderedSetInterface(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) -> bool: 16 raise NotImplementedError
17
[docs] 18 @abstractmethod 19 def discard(self, key: T) -> bool: 20 raise NotImplementedError
21
[docs] 22 @abstractmethod 23 def remove(self, key: T) -> None: 24 raise NotImplementedError
25
[docs] 26 @abstractmethod 27 def le(self, key: T) -> Optional[T]: 28 raise NotImplementedError
29
[docs] 30 @abstractmethod 31 def lt(self, key: T) -> Optional[T]: 32 raise NotImplementedError
33
[docs] 34 @abstractmethod 35 def ge(self, key: T) -> Optional[T]: 36 raise NotImplementedError
37
[docs] 38 @abstractmethod 39 def gt(self, key: T) -> Optional[T]: 40 raise NotImplementedError
41
[docs] 42 @abstractmethod 43 def get_max(self) -> Optional[T]: 44 raise NotImplementedError
45
[docs] 46 @abstractmethod 47 def get_min(self) -> Optional[T]: 48 raise NotImplementedError
49
[docs] 50 @abstractmethod 51 def pop_max(self) -> T: 52 raise NotImplementedError
53
[docs] 54 @abstractmethod 55 def pop_min(self) -> T: 56 raise NotImplementedError
57
[docs] 58 @abstractmethod 59 def clear(self) -> None: 60 raise NotImplementedError
61
[docs] 62 @abstractmethod 63 def tolist(self) -> list[T]: 64 raise NotImplementedError
65 66 @abstractmethod 67 def __iter__(self) -> Iterator: 68 raise NotImplementedError 69 70 @abstractmethod 71 def __next__(self) -> T: 72 raise NotImplementedError 73 74 @abstractmethod 75 def __contains__(self, key: T) -> bool: 76 raise NotImplementedError 77 78 @abstractmethod 79 def __len__(self) -> int: 80 raise NotImplementedError 81 82 @abstractmethod 83 def __bool__(self) -> bool: 84 raise NotImplementedError 85 86 @abstractmethod 87 def __str__(self) -> str: 88 raise NotImplementedError 89 90 @abstractmethod 91 def __repr__(self) -> str: 92 raise NotImplementedError