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