File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -275,17 +275,21 @@ template <typename T> class CircularArrayRef {
275
275
: public std::iterator<std::input_iterator_tag, T, ssize_t > {
276
276
llvm::ArrayRef<T> Array;
277
277
size_t Index;
278
+ size_t Offset;
278
279
279
280
public:
280
281
explicit const_iterator (llvm::ArrayRef<T> Array, size_t Index = 0 )
281
- : Array(Array), Index(Index) {}
282
+ : Array(Array), Index(Index), Offset(Index % Array.size()) {}
282
283
const_iterator &operator ++() {
283
284
++Index;
285
+ ++Offset;
286
+ if (Offset == Array.size ())
287
+ Offset = 0 ;
284
288
return *this ;
285
289
}
286
290
bool operator ==(const_iterator Other) const { return Index == Other.Index ; }
287
291
bool operator !=(const_iterator Other) const { return !(*this == Other); }
288
- const T &operator *() const { return Array[Index % Array. size () ]; }
292
+ const T &operator *() const { return Array[Offset ]; }
289
293
};
290
294
291
295
CircularArrayRef (llvm::ArrayRef<T> Array, size_t Size)
You can’t perform that action at this time.
0 commit comments