ORIGINAL
Loading...
Searching...
No Matches
comparator.h
1#ifndef COMPARATOR_H
2#define COMPARATOR_H
3
4namespace original
5{
6 template<typename TYPE>
7 class comparator{
8 public:
9 virtual ~comparator() = default;
10 virtual bool compare(const TYPE& t1, const TYPE& t2) const = 0;
11 bool operator()(const TYPE& t1, const TYPE& t2) const;
12 };
13
14 template<typename TYPE>
15 class increaseComparator final : public comparator<TYPE>{
16 public:
17 bool compare(const TYPE& t1, const TYPE& t2) const override;
18 };
19
20 template<typename TYPE>
21 class decreaseComparator final : public comparator<TYPE>{
22 public:
23 bool compare(const TYPE& t1, const TYPE& t2) const override;
24 };
25
26 template<typename TYPE>
27 class equalComparator final : public comparator<TYPE> {
28 public:
29 bool compare(const TYPE& t1, const TYPE& t2) const override;
30 };
31
32 template<typename TYPE>
33 class notEqualComparator final : public comparator<TYPE> {
34 public:
35 bool compare(const TYPE& t1, const TYPE& t2) const override;
36 };
37
38 template<typename TYPE>
39 class increaseNotStrictComparator final : public comparator<TYPE>{
40 public:
41 bool compare(const TYPE& t1, const TYPE& t2) const override;
42 };
43
44 template<typename TYPE>
45 class decreaseNotStrictComparator final : public comparator<TYPE>{
46 public:
47 bool compare(const TYPE& t1, const TYPE& t2) const override;
48 };
49
50}
51
52 template <typename TYPE>
53 auto original::comparator<TYPE>::operator()(const TYPE& t1, const TYPE& t2) const -> bool
54 {
55 return this->compare(t1, t2);
56 }
57
58 template <typename TYPE>
59 auto original::increaseComparator<TYPE>::compare(const TYPE& t1, const TYPE& t2) const -> bool
60 {
61 return t1 < t2;
62 }
63
64 template<typename TYPE>
65 auto original::decreaseComparator<TYPE>::compare(const TYPE& t1, const TYPE& t2) const -> bool
66 {
67 return t1 > t2;
68 }
69
70 template <typename TYPE>
71 auto original::equalComparator<TYPE>::compare(const TYPE& t1, const TYPE& t2) const -> bool
72 {
73 return t1 == t2;
74 }
75
76 template <typename TYPE>
77 auto original::notEqualComparator<TYPE>::compare(const TYPE& t1, const TYPE& t2) const -> bool
78 {
79 return t1 != t2;
80 }
81
82template<typename TYPE>
83 auto original::increaseNotStrictComparator<TYPE>::compare(const TYPE& t1, const TYPE& t2) const -> bool
84 {
85 return t1 < t2 || t1 == t2;
86 }
87
88
89 template <typename TYPE>
90 auto original::decreaseNotStrictComparator<TYPE>::compare(const TYPE& t1, const TYPE& t2) const -> bool
91 {
92 return t1 > t2 || t1 == t2;
93 }
94
95#endif //COMPARATOR_H
Definition comparator.h:7
Definition comparator.h:21
Definition comparator.h:45
Definition comparator.h:27
Definition comparator.h:15
Definition comparator.h:39
Definition comparator.h:33