hyperloglog_rs/
max_min.rs1pub trait MaxMin: PartialOrd {
4 fn get_max(self, other: Self) -> Self;
17
18 fn get_min(self, other: Self) -> Self;
31
32 fn non_zero_positive_min_value() -> Self;
45}
46
47impl MaxMin for f32 {
48 #[inline(always)]
49 fn get_max(self, other: Self) -> Self {
50 self.max(other)
51 }
52
53 #[inline(always)]
54 fn get_min(self, other: Self) -> Self {
55 self.min(other)
56 }
57
58 #[inline(always)]
59 fn non_zero_positive_min_value() -> Self {
60 Self::EPSILON
61 }
62}
63
64impl MaxMin for f64 {
65 #[inline(always)]
66 fn get_max(self, other: Self) -> Self {
67 self.max(other)
68 }
69
70 #[inline(always)]
71 fn get_min(self, other: Self) -> Self {
72 self.min(other)
73 }
74
75 #[inline(always)]
76 fn non_zero_positive_min_value() -> Self {
77 Self::EPSILON
78 }
79}
80
81impl MaxMin for u8 {
82 #[inline(always)]
83 fn get_max(self, other: Self) -> Self {
84 self.max(other)
85 }
86
87 #[inline(always)]
88 fn get_min(self, other: Self) -> Self {
89 self.min(other)
90 }
91
92 #[inline(always)]
93 fn non_zero_positive_min_value() -> Self {
94 1
95 }
96}
97
98impl MaxMin for u16 {
99 #[inline(always)]
100 fn get_max(self, other: Self) -> Self {
101 self.max(other)
102 }
103
104 #[inline(always)]
105 fn get_min(self, other: Self) -> Self {
106 self.min(other)
107 }
108
109 #[inline(always)]
110 fn non_zero_positive_min_value() -> Self {
111 1
112 }
113}
114
115impl MaxMin for u32 {
116 #[inline(always)]
117 fn get_max(self, other: Self) -> Self {
118 self.max(other)
119 }
120
121 #[inline(always)]
122 fn get_min(self, other: Self) -> Self {
123 self.min(other)
124 }
125
126 #[inline(always)]
127 fn non_zero_positive_min_value() -> Self {
128 1
129 }
130}
131
132impl MaxMin for u64 {
133 #[inline(always)]
134 fn get_max(self, other: Self) -> Self {
135 self.max(other)
136 }
137
138 #[inline(always)]
139 fn get_min(self, other: Self) -> Self {
140 self.min(other)
141 }
142
143 #[inline(always)]
144 fn non_zero_positive_min_value() -> Self {
145 1
146 }
147}
148
149impl MaxMin for u128 {
150 #[inline(always)]
151 fn get_max(self, other: Self) -> Self {
152 self.max(other)
153 }
154
155 #[inline(always)]
156 fn get_min(self, other: Self) -> Self {
157 self.min(other)
158 }
159
160 #[inline(always)]
161 fn non_zero_positive_min_value() -> Self {
162 1
163 }
164}
165
166impl MaxMin for usize {
167 #[inline(always)]
168 fn get_max(self, other: Self) -> Self {
169 self.max(other)
170 }
171
172 #[inline(always)]
173 fn get_min(self, other: Self) -> Self {
174 self.min(other)
175 }
176
177 #[inline(always)]
178 fn non_zero_positive_min_value() -> Self {
179 1
180 }
181}
182
183impl MaxMin for i8 {
184 #[inline(always)]
185 fn get_max(self, other: Self) -> Self {
186 self.max(other)
187 }
188
189 #[inline(always)]
190 fn get_min(self, other: Self) -> Self {
191 self.min(other)
192 }
193
194 #[inline(always)]
195 fn non_zero_positive_min_value() -> Self {
196 1
197 }
198}
199
200impl MaxMin for i16 {
201 #[inline(always)]
202 fn get_max(self, other: Self) -> Self {
203 self.max(other)
204 }
205
206 #[inline(always)]
207 fn get_min(self, other: Self) -> Self {
208 self.min(other)
209 }
210
211 #[inline(always)]
212 fn non_zero_positive_min_value() -> Self {
213 1
214 }
215}
216
217impl MaxMin for i32 {
218 #[inline(always)]
219 fn get_max(self, other: Self) -> Self {
220 self.max(other)
221 }
222
223 #[inline(always)]
224 fn get_min(self, other: Self) -> Self {
225 self.min(other)
226 }
227
228 #[inline(always)]
229 fn non_zero_positive_min_value() -> Self {
230 1
231 }
232}
233
234impl MaxMin for i64 {
235 #[inline(always)]
236 fn get_max(self, other: Self) -> Self {
237 self.max(other)
238 }
239
240 #[inline(always)]
241 fn get_min(self, other: Self) -> Self {
242 self.min(other)
243 }
244
245 #[inline(always)]
246 fn non_zero_positive_min_value() -> Self {
247 1
248 }
249}
250
251impl MaxMin for i128 {
252 #[inline(always)]
253 fn get_max(self, other: Self) -> Self {
254 self.max(other)
255 }
256
257 #[inline(always)]
258 fn get_min(self, other: Self) -> Self {
259 self.min(other)
260 }
261
262 #[inline(always)]
263 fn non_zero_positive_min_value() -> Self {
264 1
265 }
266}