@@ -74,56 +74,56 @@ template <typename T, typename IntervalType> class IntervalIterator {
74
74
};
75
75
76
76
template <typename T> class Interval {
77
- T *From ;
78
- T *To ;
77
+ T *Top ;
78
+ T *Bottom ;
79
79
80
80
public:
81
- Interval () : From (nullptr ), To (nullptr ) {}
82
- Interval (T *From , T *To ) : From(From ), To(To ) {
83
- assert ((From == To || From ->comesBefore (To )) &&
84
- " From should come before From !" );
81
+ Interval () : Top (nullptr ), Bottom (nullptr ) {}
82
+ Interval (T *Top , T *Bottom ) : Top(Top ), Bottom(Bottom ) {
83
+ assert ((Top == Bottom || Top ->comesBefore (Bottom )) &&
84
+ " Top should come before Bottom !" );
85
85
}
86
86
Interval (ArrayRef<T *> Elems) {
87
87
assert (!Elems.empty () && " Expected non-empty Elems!" );
88
- From = Elems[0 ];
89
- To = Elems[0 ];
88
+ Top = Elems[0 ];
89
+ Bottom = Elems[0 ];
90
90
for (auto *I : drop_begin (Elems)) {
91
- if (I->comesBefore (From ))
92
- From = I;
93
- else if (To ->comesBefore (I))
94
- To = I;
91
+ if (I->comesBefore (Top ))
92
+ Top = I;
93
+ else if (Bottom ->comesBefore (I))
94
+ Bottom = I;
95
95
}
96
96
}
97
97
bool empty () const {
98
- assert (((From == nullptr && To == nullptr ) ||
99
- (From != nullptr && To != nullptr )) &&
98
+ assert (((Top == nullptr && Bottom == nullptr ) ||
99
+ (Top != nullptr && Bottom != nullptr )) &&
100
100
" Either none or both should be null" );
101
- return From == nullptr ;
101
+ return Top == nullptr ;
102
102
}
103
103
bool contains (T *I) const {
104
104
if (empty ())
105
105
return false ;
106
- return (From == I || From ->comesBefore (I)) &&
107
- (I == To || I->comesBefore (To ));
106
+ return (Top == I || Top ->comesBefore (I)) &&
107
+ (I == Bottom || I->comesBefore (Bottom ));
108
108
}
109
- T *top () const { return From ; }
110
- T *bottom () const { return To ; }
109
+ T *top () const { return Top ; }
110
+ T *bottom () const { return Bottom ; }
111
111
112
112
using iterator = IntervalIterator<T, Interval>;
113
- iterator begin () { return iterator (From , *this ); }
113
+ iterator begin () { return iterator (Top , *this ); }
114
114
iterator end () {
115
- return iterator (To != nullptr ? To ->getNextNode () : nullptr , *this );
115
+ return iterator (Bottom != nullptr ? Bottom ->getNextNode () : nullptr , *this );
116
116
}
117
117
iterator begin () const {
118
- return iterator (From , const_cast <Interval &>(*this ));
118
+ return iterator (Top , const_cast <Interval &>(*this ));
119
119
}
120
120
iterator end () const {
121
- return iterator (To != nullptr ? To ->getNextNode () : nullptr ,
121
+ return iterator (Bottom != nullptr ? Bottom ->getNextNode () : nullptr ,
122
122
const_cast <Interval &>(*this ));
123
123
}
124
124
// / Equality.
125
125
bool operator ==(const Interval &Other) const {
126
- return From == Other.From && To == Other.To ;
126
+ return Top == Other.Top && Bottom == Other.Bottom ;
127
127
}
128
128
// / Inequality.
129
129
bool operator !=(const Interval &Other) const { return !(*this == Other); }
@@ -139,7 +139,7 @@ template <typename T> class Interval {
139
139
return true ;
140
140
if (empty ())
141
141
return true ;
142
- return Other.To ->comesBefore (From ) || To ->comesBefore (Other.From );
142
+ return Other.Bottom ->comesBefore (Top ) || Bottom ->comesBefore (Other.Top );
143
143
}
144
144
// / \Returns the intersection between this and \p Other.
145
145
// Example:
@@ -154,14 +154,14 @@ template <typename T> class Interval {
154
154
// 1. No overlap
155
155
// A---B this
156
156
// C--D Other
157
- if (To ->comesBefore (Other.From ) || Other.To ->comesBefore (From ))
157
+ if (Bottom ->comesBefore (Other.Top ) || Other.Bottom ->comesBefore (Top ))
158
158
return Interval ();
159
159
// 2. Overlap.
160
160
// A---B this
161
161
// C--D Other
162
- auto NewFromI = From ->comesBefore (Other.From ) ? Other.From : From ;
163
- auto NewToI = To ->comesBefore (Other.To ) ? To : Other.To ;
164
- return Interval (NewFromI, NewToI );
162
+ auto NewTopI = Top ->comesBefore (Other.Top ) ? Other.Top : Top ;
163
+ auto NewBottomI = Bottom ->comesBefore (Other.Bottom ) ? Bottom : Other.Bottom ;
164
+ return Interval (NewTopI, NewBottomI );
165
165
}
166
166
// / Difference operation. This returns up to two intervals.
167
167
// Example:
@@ -178,11 +178,11 @@ template <typename T> class Interval {
178
178
Interval Intersection = intersection (Other);
179
179
SmallVector<Interval, 2 > Result;
180
180
// Part 1, skip if empty.
181
- if (From != Intersection.From )
182
- Result.emplace_back (From , Intersection.From ->getPrevNode ());
181
+ if (Top != Intersection.Top )
182
+ Result.emplace_back (Top , Intersection.Top ->getPrevNode ());
183
183
// Part 2, skip if empty.
184
- if (Intersection.To != To )
185
- Result.emplace_back (Intersection.To ->getNextNode (), To );
184
+ if (Intersection.Bottom != Bottom )
185
+ Result.emplace_back (Intersection.Bottom ->getNextNode (), Bottom );
186
186
return Result;
187
187
}
188
188
// / \Returns the interval difference `this - Other`. This will crash in Debug
@@ -202,9 +202,9 @@ template <typename T> class Interval {
202
202
return Other;
203
203
if (Other.empty ())
204
204
return *this ;
205
- auto *NewFrom = From ->comesBefore (Other.From ) ? From : Other.From ;
206
- auto *NewTo = To ->comesBefore (Other.To ) ? Other.To : To ;
207
- return {NewFrom, NewTo };
205
+ auto *NewTop = Top ->comesBefore (Other.Top ) ? Top : Other.Top ;
206
+ auto *NewBottom = Bottom ->comesBefore (Other.Bottom ) ? Other.Bottom : Bottom ;
207
+ return {NewTop, NewBottom };
208
208
}
209
209
210
210
#ifndef NDEBUG
0 commit comments