##// END OF EJS Templates
Improves purge method
Alexandre Leroux -
r690:03eea8848b1d
parent child
Show More
@@ -190,17 +190,28 public:
190
190
191 void purge(double min, double max) override
191 void purge(double min, double max) override
192 {
192 {
193 // Nothing to purge if series is empty
194 if (isEmpty()) {
195 return;
196 }
197
193 if (min > max) {
198 if (min > max) {
194 std::swap(min, max);
199 std::swap(min, max);
195 }
200 }
196
201
197 lockWrite();
202 // Nothing to purge if series min/max are inside purge range
198
203 auto xMin = cbegin()->x();
199 auto it = std::remove_if(
204 auto xMax = (--cend())->x();
200 begin(), end(), [min, max](const auto &it) { return it.x() < min || it.x() > max; });
205 if (xMin >= min && xMax <= max) {
201 erase(it, end());
206 return;
207 }
202
208
203 unlock();
209 auto lowerIt = std::lower_bound(
210 begin(), end(), min, [](const auto &it, const auto &val) { return it.x() < val; });
211 erase(begin(), lowerIt);
212 auto upperIt = std::upper_bound(
213 begin(), end(), max, [](const auto &val, const auto &it) { return val < it.x(); });
214 erase(upperIt, end());
204 }
215 }
205
216
206 // ///////// //
217 // ///////// //
General Comments 0
You need to be logged in to leave comments. Login now