MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Iterator

Class Iterator

Source/Engine/Core/Collections/ChunkedArray.h:95–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 /// Chunked array iterator.
94 /// </summary>
95 struct Iterator
96 {
97 friend ChunkedArray;
98 private:
99 ChunkedArray* _collection;
100 int32 _chunkIndex;
101 int32 _index;
102
103 Iterator(const ChunkedArray* collection, const int32 index)
104 : _collection(const_cast<ChunkedArray*>(collection))
105 , _chunkIndex(index / ChunkSize)
106 , _index(index % ChunkSize)
107 {
108 }
109
110 public:
111 Iterator()
112 : _collection(nullptr)
113 , _chunkIndex(INVALID_INDEX)
114 , _index(INVALID_INDEX)
115 {
116 }
117
118 Iterator(const Iterator& i)
119 : _collection(i._collection)
120 , _chunkIndex(i._chunkIndex)
121 , _index(i._index)
122 {
123 }
124
125 Iterator(Iterator&& i)
126 : _collection(i._collection)
127 , _chunkIndex(i._chunkIndex)
128 , _index(i._index)
129 {
130 }
131
132 public:
133 FORCE_INLINE int32 Index() const
134 {
135 return _chunkIndex * ChunkSize + _index;
136 }
137
138 FORCE_INLINE bool IsEnd() const
139 {
140 return (_chunkIndex * ChunkSize + _index) == _collection->_count;
141 }
142
143 FORCE_INLINE bool IsNotEnd() const
144 {
145 return (_chunkIndex * ChunkSize + _index) != _collection->_count;
146 }
147
148 FORCE_INLINE T& operator*() const
149 {
150 return _collection->_chunks[_chunkIndex]->At(_index);
151 }
152

Callers 5

BeginMethod · 0.70
EndMethod · 0.70
IteratorAtMethod · 0.70
beginMethod · 0.70
endMethod · 0.70

Calls 1

CountMethod · 0.45

Tested by

no test coverage detected