MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / Iter

Class Iter

src/Core/include/OpenLoco/Core/LocoFixedVector.hpp:13–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11 ValueType* startAddress = nullptr;
12
13 class Iter
14 {
15 private:
16 ValueType* arr;
17 size_t i = 0;
18
19 constexpr void findNonEmpty()
20 {
21 for (; i < Count; ++i)
22 {
23 if (!arr[i].empty())
24 {
25 break;
26 }
27 }
28 }
29
30 public:
31 constexpr Iter(ValueType* _arr, size_t _index)
32 : arr(_arr)
33 , i(_index)
34 {
35 // finds first valid entry
36 findNonEmpty();
37 }
38
39 constexpr Iter& operator++()
40 {
41 ++i;
42 findNonEmpty();
43 return *this;
44 }
45
46 constexpr Iter operator++(int)
47 {
48 Iter retval = *this;
49 ++(*this);
50 return retval;
51 }
52
53 constexpr bool operator==(Iter other) const
54 {
55 return i == other.i;
56 }
57
58 constexpr ValueType& operator*() const
59 {
60 return arr[i];
61 }
62 // iterator traits
63 using difference_type = std::ptrdiff_t;
64 using value_type = ValueType;
65 using pointer = ValueType*;
66 using reference = ValueType&;
67 using iterator_category = std::forward_iterator_tag;
68 };
69
70 public:

Callers 2

beginMethod · 0.85
endMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected