P4C
The P4 Compiler
Loading...
Searching...
No Matches
field_slice_set.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PARDE_CLOT_FIELD_SLICE_SET_H_
20#define BACKENDS_TOFINO_BF_P4C_PARDE_CLOT_FIELD_SLICE_SET_H_
21
22#include "bf-p4c/phv/phv_fields.h"
23
25class FieldSliceSet : public std::set<const PHV::FieldSlice *, PHV::FieldSlice::Less> {
26 public:
27 using std::set<const PHV::FieldSlice *, PHV::FieldSlice::Less>::set;
28
29 bool operator==(const FieldSliceSet &other) const {
30 if (size() != other.size()) return false;
31
32 auto it1 = begin();
33 auto it2 = other.begin();
34 while (it1 != end()) {
35 if (!PHV::FieldSlice::equal(*it1, *it2)) return false;
36 ++it1;
37 ++it2;
38 }
39
40 return true;
41 }
42
43 bool operator<(const FieldSliceSet &other) const {
44 if (size() != other.size()) return size() < other.size();
45
46 auto it1 = begin();
47 auto it2 = other.begin();
48 while (it1 != end()) {
49 if (!PHV::FieldSlice::equal(*it1, *it2)) return PHV::FieldSlice::less(*it1, *it2);
50 ++it1;
51 ++it2;
52 }
53
54 return false;
55 }
56
57 bool operator>(const FieldSliceSet &other) const {
58 if (size() != other.size()) return size() > other.size();
59
60 auto it1 = begin();
61 auto it2 = other.begin();
62 while (it1 != end()) {
63 if (!PHV::FieldSlice::equal(*it1, *it2)) return PHV::FieldSlice::greater(*it1, *it2);
64 ++it1;
65 ++it2;
66 }
67
68 return false;
69 }
70
71 bool operator!=(const FieldSliceSet &other) const { return !operator==(other); }
72
73 bool operator<=(const FieldSliceSet &other) const { return !operator>(other); }
74
75 bool operator>=(const FieldSliceSet &other) const { return !operator<(other); }
76};
77
79
80#endif /* BACKENDS_TOFINO_BF_P4C_PARDE_CLOT_FIELD_SLICE_SET_H_ */
Implements comparisons correctly.
Definition field_slice_set.h:25
Definition phv_fields.h:898