1# from titan_pylib.data_structures.segment_tree.segment_tree_interface import SegmentTreeInterface
2from abc import ABC, abstractmethod
3from typing import TypeVar, Generic, Union, Iterable, Callable
4
5T = TypeVar("T")
6
7
8class SegmentTreeInterface(ABC, Generic[T]):
9
10 @abstractmethod
11 def __init__(self, n_or_a: Union[int, Iterable[T]], op: Callable[[T, T], T], e: T):
12 raise NotImplementedError
13
14 @abstractmethod
15 def set(self, k: int, v: T) -> None:
16 raise NotImplementedError
17
18 @abstractmethod
19 def get(self, k: int) -> T:
20 raise NotImplementedError
21
22 @abstractmethod
23 def prod(self, l: int, r: int) -> T:
24 raise NotImplementedError
25
26 @abstractmethod
27 def all_prod(self) -> T:
28 raise NotImplementedError
29
30 @abstractmethod
31 def max_right(self, l: int, f: Callable[[T], bool]) -> int:
32 raise NotImplementedError
33
34 @abstractmethod
35 def min_left(self, r: int, f: Callable[[T], bool]) -> int:
36 raise NotImplementedError
37
38 @abstractmethod
39 def tolist(self) -> list[T]:
40 raise NotImplementedError
41
42 @abstractmethod
43 def __getitem__(self, k: int) -> T:
44 raise NotImplementedError
45
46 @abstractmethod
47 def __setitem__(self, k: int, v: T) -> None:
48 raise NotImplementedError
49
50 @abstractmethod
51 def __str__(self):
52 raise NotImplementedError
53
54 @abstractmethod
55 def __repr__(self):
56 raise NotImplementedError