-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlimits.py
47 lines (33 loc) · 1.08 KB
/
limits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
This module is a Python replacement for some of C/C++ limits.h constants.
It's useful for some algorithms where you need to find max or min element
or check if some value exceeds some limits
and you cannot get some existing value as the starting point (because it's unknown at the moment) or it's inconvenient.
P.S. For numbers you should probably use math.inf and -math.inf
"""
class __Maximum:
"""
The Maximum which is bigger than everything and not equal to anything (including itself). Almost like +Infinity
"""
def __eq__(self, x):
return False
def __ne__(self, x):
return True
def __gt__(self, x):
return True
def __ge__(self, x):
return True
maximum = __Maximum()
class __Minimum:
"""
The Minimum which is smaller than everything and not equal to anything (including itself). Almost like -Infinity
"""
def __eq__(self, x):
return False
def __ne__(self, x):
return True
def __lt__(self, x):
return True
def __le__(self, x):
return True
minimum = __Minimum()