@@ -209,35 +209,33 @@ template <typename T, size_t PageSize = 1024 / sizeof(T)> class PagedVector {
209
209
return PagePtr[ElementIdx % PageSize];
210
210
}
211
211
212
- friend bool operator ==(MaterializedIterator const &LHS,
213
- MaterializedIterator const &RHS);
214
- friend bool operator !=(MaterializedIterator const &LHS,
215
- MaterializedIterator const &RHS);
212
+ // / Equality operator.
213
+ friend bool operator ==(const MaterializedIterator &LHS,
214
+ const MaterializedIterator &RHS) {
215
+ return LHS.equals (RHS);
216
+ }
216
217
217
218
[[nodiscard]] size_t getIndex () const { return ElementIdx; }
218
- };
219
219
220
- // / Equality operator.
221
- friend bool operator ==(MaterializedIterator const &LHS,
222
- MaterializedIterator const &RHS) {
223
- assert (LHS.PV == RHS.PV );
224
- // Make sure we are comparing either end iterators or iterators pointing
225
- // to materialized elements.
226
- // It should not be possible to build two iterators pointing to non
227
- // materialized elements.
228
- assert (LHS.ElementIdx == LHS.PV ->Size ||
229
- (LHS.ElementIdx < LHS.PV ->Size &&
230
- LHS.PV ->PageToDataPtrs [LHS.ElementIdx / PageSize]));
231
- assert (RHS.ElementIdx == RHS.PV ->Size ||
232
- (RHS.ElementIdx < RHS.PV ->Size &&
233
- RHS.PV ->PageToDataPtrs [RHS.ElementIdx / PageSize]));
234
- return LHS.ElementIdx == RHS.ElementIdx ;
235
- }
220
+ friend bool operator !=(const MaterializedIterator &LHS,
221
+ const MaterializedIterator &RHS) {
222
+ return !(LHS == RHS);
223
+ }
236
224
237
- friend bool operator !=(MaterializedIterator const &LHS,
238
- MaterializedIterator const &RHS) {
239
- return !(LHS == RHS);
240
- }
225
+ private:
226
+ void verify () const {
227
+ assert (
228
+ ElementIdx == PV->Size ||
229
+ (ElementIdx < PV->Size && PV->PageToDataPtrs [ElementIdx / PageSize]));
230
+ }
231
+
232
+ bool equals (const MaterializedIterator &Other) const {
233
+ assert (PV == Other.PV );
234
+ verify ();
235
+ Other.verify ();
236
+ return ElementIdx == Other.ElementIdx ;
237
+ }
238
+ };
241
239
242
240
// / Iterators over the materialized elements of the vector.
243
241
// /
0 commit comments