MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / firstNItemsAreEqual

Function firstNItemsAreEqual

radiantcore/patch/algorithm/General.cpp:173–194  ·  view source on GitHub ↗

Returns true if elements in the given sequences are equal

Source from the content-addressed store, hash-verified

171
172// Returns true if <num> elements in the given sequences are equal
173inline bool firstNItemsAreEqual(const PatchControlIterator& sequence1,
174 const PatchControlIterator& sequence2, std::size_t num, double epsilon)
175{
176 // If the iterators are invalid from the start, return false
177 if (!sequence1.isValid() || !sequence2.isValid())
178 {
179 return false;
180 }
181
182 auto p1 = sequence1;
183 auto p2 = sequence2;
184
185 for (std::size_t n = 0; n < num && p1.isValid() && p2.isValid(); ++n, ++p1, ++p2)
186 {
187 if (!math::isNear(p1->vertex, p2->vertex, epsilon))
188 {
189 return false;
190 }
191 }
192
193 return true;
194}
195
196// Copies all values from source to target, until the source sequence is depleted
197// Returns the new position of the target iterator

Callers 1

createdMergedPatchFunction · 0.85

Calls 2

isNearFunction · 0.50
isValidMethod · 0.45

Tested by

no test coverage detected