##// END OF EJS Templates
Improves random access iterator performance
Alexandre Leroux -
r647:710e631137a0 feature/ImprovePe...
parent child
Show More
@@ -121,13 +121,11 public:
121 121 std::unique_ptr<ArrayDataIteratorValue::Impl> advance(int offset) const override
122 122 {
123 123 auto result = clone();
124 while (offset--) {
125 result->next();
126 }
124 result->next(offset);
127 125 return result;
128 126 }
129 127
130 void next() override { std::advance(m_It, m_NbComponents); }
128 void next(int offset) override { std::advance(m_It, offset * m_NbComponents); }
131 129 void prev() override { std::advance(m_It, -m_NbComponents); }
132 130
133 131 double at(int componentIndex) const override { return *(m_It + componentIndex); }
@@ -23,7 +23,7 public:
23 23 virtual bool equals(const Impl &other) const = 0;
24 24 virtual bool lowerThan(const Impl &other) const = 0;
25 25 virtual std::unique_ptr<Impl> advance(int offset) const = 0;
26 virtual void next() = 0;
26 virtual void next(int offset) = 0;
27 27 virtual void prev() = 0;
28 28 virtual double at(int componentIndex) const = 0;
29 29 virtual double first() const = 0;
@@ -44,7 +44,7 public:
44 44
45 45 ArrayDataIteratorValue advance(int offset) const;
46 46 /// Advances to the next value
47 void next();
47 void next(int offset = 1);
48 48 /// Moves back to the previous value
49 49 void prev();
50 50 /// Gets value of a specified component
@@ -81,16 +81,14 public:
81 81 std::unique_ptr<DataSeriesIteratorValue::Impl> advance(int offset) const override
82 82 {
83 83 auto result = clone();
84 while (offset--) {
85 result->next();
86 }
84 result->next(offset);
87 85 return result;
88 86 }
89 87
90 void next() override
88 void next(int offset) override
91 89 {
92 ++m_XIt;
93 ++m_ValuesIt;
90 m_XIt->next(offset);
91 m_ValuesIt->next(offset);
94 92 }
95 93
96 94 void prev() override
@@ -24,7 +24,7 public:
24 24 virtual bool equals(const Impl &other) const = 0;
25 25 virtual bool lowerThan(const Impl &other) const = 0;
26 26 virtual std::unique_ptr<Impl> advance(int offset) const = 0;
27 virtual void next() = 0;
27 virtual void next(int offset) = 0;
28 28 virtual void prev() = 0;
29 29 virtual double x() const = 0;
30 30 virtual double value() const = 0;
@@ -46,7 +46,7 public:
46 46
47 47 DataSeriesIteratorValue advance(int offset) const;
48 48 /// Advances to the next value
49 void next();
49 void next(int offset = 1);
50 50 /// Moves back to the previous value
51 51 void prev();
52 52 /// Gets x-axis data
@@ -52,9 +52,7 public:
52 52 SqpIterator &operator+=(int offset)
53 53 {
54 54 if (offset >= 0) {
55 while (offset--) {
56 m_CurrentValue.next();
57 }
55 m_CurrentValue.next(offset);
58 56 }
59 57 else {
60 58 while (offset++) {
@@ -36,9 +36,9 ArrayDataIteratorValue ArrayDataIteratorValue::advance(int offset) const
36 36 return ArrayDataIteratorValue{m_Impl->advance(offset)};
37 37 }
38 38
39 void ArrayDataIteratorValue::next()
39 void ArrayDataIteratorValue::next(int offset)
40 40 {
41 m_Impl->next();
41 m_Impl->next(offset);
42 42 }
43 43
44 44 void ArrayDataIteratorValue::prev()
@@ -38,9 +38,9 DataSeriesIteratorValue DataSeriesIteratorValue::advance(int offset) const
38 38 return DataSeriesIteratorValue{m_Impl->advance(offset)};
39 39 }
40 40
41 void DataSeriesIteratorValue::next()
41 void DataSeriesIteratorValue::next(int offset)
42 42 {
43 m_Impl->next();
43 m_Impl->next(offset);
44 44 }
45 45
46 46 void DataSeriesIteratorValue::prev()
General Comments 0
You need to be logged in to leave comments. Login now