Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions core/cont/inc/ROOT/TSeq.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -92,33 +92,37 @@ namespace ROOT {
T operator*() const {
return fCounter;
}
iterator &operator++() {
fCounter += fStep;
return *this;
};
iterator operator++(int) {
iterator tmp(*this);
operator++();
return tmp;
}
// equality
bool operator==(const iterator &other) const {
return fCounter == other.fCounter;
}
// inequality
bool operator!=(const iterator &other) const {
return fCounter != other.fCounter;
}
T operator+(int v) const {
return fCounter + v;
// sum with integer
iterator operator+(difference_type v) const {
return iterator(fCounter + v * fStep, fStep);
}
T operator-(int v) const {
return fCounter - v;
// difference with integer
iterator operator-(difference_type v) const {
return iterator(fCounter - v * fStep, fStep);
}
T operator+(const iterator &other) const {
return fCounter + other.fCounter;
// distance
difference_type operator-(const iterator &other) const {
return (fCounter - other.fCounter) / fStep;
}
// increments
iterator &operator++() {
fCounter += fStep;
return *this;
}
T operator-(const iterator &other) const {
return fCounter - other.fCounter;
iterator operator++(int) {
iterator tmp(*this);
operator++();
return tmp;
}
// decrements
iterator &operator--() {
fCounter -= fStep;
return *this;
Expand All @@ -128,14 +132,23 @@ namespace ROOT {
operator--();
return tmp;
}
// compound assignments
iterator &operator+=(const difference_type& v) {
*this = *this + v;
return *this;
}
iterator &operator-=(const difference_type& v) {
*this = *this - v;
return *this;
}
};

iterator begin() const {
return iterator(fBegin, fStep);
}
iterator end() const {
auto isStepMultiple = (fEnd - fBegin) % fStep == 0;
auto theEnd = isStepMultiple ? fEnd : fStep * ((T)((fEnd - fBegin) / fStep) + 1) + fBegin;
auto theEnd = isStepMultiple ? fEnd : fStep * (((fEnd - fBegin) / fStep) + 1) + fBegin;
return iterator(theEnd, fStep);
}

Expand Down