GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 11
Functions: -% 0 / 0 / 0
Branches: -% 0 / 0 / 0

ds/cnt_min.hpp
Line Branch Exec Source
1 #pragma once
2
3 #include "reverse_comparator.hpp"
4
5 namespace wala {
6
7 template <typename T, typename C = int, typename Comp = std::less<T>> struct cnt_min {
8 T v;
9 C cnt;
10
11 ✗ cnt_min() : v(), cnt(0) {}
12 ✗ explicit cnt_min(T v_) : v(v_), cnt(1) {}
13 ✗ cnt_min(T v_, C cnt_) : v(v_), cnt(cnt_) {}
14
15 ✗ friend cnt_min operator + (const cnt_min& a, const cnt_min& b) {
16 ✗ if (!b.cnt) return a;
17 ✗ else if (!a.cnt) return b;
18 ✗ else if (Comp().operator()(a.v, b.v)) return a;
19 ✗ else if (Comp().operator()(b.v, a.v)) return b;
20 ✗ else return cnt_min(a.v, a.cnt + b.cnt);
21 }
22
23 ✗ cnt_min& operator += (const cnt_min& o) {
24 ✗ return *this = (*this + o);
25 }
26 };
27
28 template <typename T, typename C = int, typename Comp = std::less<T>> using cnt_max = cnt_min<T, C, reverse_comparator_t<Comp>>;
29
30 } // namespace wala
31