MCPcopy Create free account
hub / github.com/cvanaret/Uno / iterator

Class iterator

uno/linear_algebra/SparseVector.hpp:18–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 class SparseVector {
17 public:
18 class iterator {
19 public:
20 using value_type = std::pair<size_t, ElementType>;
21
22 iterator(const SparseVector& vector, size_t index): vector(vector), index(index) { }
23
24 value_type operator*() const {
25 return {this->vector.indices[this->index], this->vector.values[this->index]};
26 }
27
28 iterator& operator++() {
29 ++this->index;
30 return *this;
31 }
32
33 friend bool operator!=(const iterator& a, const iterator& b) {
34 return &a.vector != &b.vector || a.index != b.index;
35 }
36
37 friend bool operator==(const iterator& a, const iterator& b) {
38 return &a.vector == &b.vector && a.index == b.index;
39 }
40
41 protected:
42 const SparseVector& vector;
43 size_t index;
44 };
45
46 using value_type = ElementType;
47

Callers 2

beginMethod · 0.70
endMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected