ordered_multiset_interface

ソースコード

from titan_pylib.my_class.ordered_multiset_interface import OrderedMultisetInterface

view on github

展開済みコード

  1# from titan_pylib.my_class.ordered_multiset_interface import OrderedMultisetInterface
  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 OrderedMultisetInterface(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, cnt: int) -> None:
 23        raise NotImplementedError
 24
 25    @abstractmethod
 26    def discard(self, key: T, cnt: int) -> bool:
 27        raise NotImplementedError
 28
 29    @abstractmethod
 30    def discard_all(self, key: T) -> bool:
 31        raise NotImplementedError
 32
 33    @abstractmethod
 34    def count(self, key: T) -> int:
 35        raise NotImplementedError
 36
 37    @abstractmethod
 38    def remove(self, key: T, cnt: int) -> None:
 39        raise NotImplementedError
 40
 41    @abstractmethod
 42    def le(self, key: T) -> Optional[T]:
 43        raise NotImplementedError
 44
 45    @abstractmethod
 46    def lt(self, key: T) -> Optional[T]:
 47        raise NotImplementedError
 48
 49    @abstractmethod
 50    def ge(self, key: T) -> Optional[T]:
 51        raise NotImplementedError
 52
 53    @abstractmethod
 54    def gt(self, key: T) -> Optional[T]:
 55        raise NotImplementedError
 56
 57    @abstractmethod
 58    def get_max(self) -> Optional[T]:
 59        raise NotImplementedError
 60
 61    @abstractmethod
 62    def get_min(self) -> Optional[T]:
 63        raise NotImplementedError
 64
 65    @abstractmethod
 66    def pop_max(self) -> T:
 67        raise NotImplementedError
 68
 69    @abstractmethod
 70    def pop_min(self) -> T:
 71        raise NotImplementedError
 72
 73    @abstractmethod
 74    def clear(self) -> None:
 75        raise NotImplementedError
 76
 77    @abstractmethod
 78    def tolist(self) -> list[T]:
 79        raise NotImplementedError
 80
 81    @abstractmethod
 82    def __iter__(self) -> Iterator:
 83        raise NotImplementedError
 84
 85    @abstractmethod
 86    def __next__(self) -> T:
 87        raise NotImplementedError
 88
 89    @abstractmethod
 90    def __contains__(self, key: T) -> bool:
 91        raise NotImplementedError
 92
 93    @abstractmethod
 94    def __len__(self) -> int:
 95        raise NotImplementedError
 96
 97    @abstractmethod
 98    def __bool__(self) -> bool:
 99        raise NotImplementedError
100
101    @abstractmethod
102    def __str__(self) -> str:
103        raise NotImplementedError
104
105    @abstractmethod
106    def __repr__(self) -> str:
107        raise NotImplementedError

仕様

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

Bases: ABC, Generic[T]

abstractmethod add(key: T, cnt: int) None[source]
abstractmethod clear() None[source]
abstractmethod count(key: T) int[source]
abstractmethod discard(key: T, cnt: int) bool[source]
abstractmethod discard_all(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, cnt: int) None[source]
abstractmethod tolist() list[T][source]