MCPcopy Create free account
hub / github.com/Gecode/gecode / two

Method two

gecode/iter/ranges-union.hpp:181–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179
180 template<class I, class J>
181 RangeListIter::RangeList*
182 NaryUnion::two(I& i, J& j) {
183 RangeList* h;
184 RangeList** c = &h;
185
186 while (i() && j())
187 if (i.max()+1 < j.min()) {
188 RangeList* t = range(i); ++i;
189 *c = t; c = &t->next;
190 } else if (j.max()+1 < i.min()) {
191 RangeList* t = range(j); ++j;
192 *c = t; c = &t->next;
193 } else {
194 int min = std::min(i.min(),j.min());
195 int max = std::max(i.max(),j.max());
196 ++i; ++j;
197
198 nexta:
199 if (i() && (i.min() <= max+1)) {
200 max = std::max(max,i.max()); ++i;
201 goto nexta;
202 }
203 if (j() && (j.min() <= max+1)) {
204 max = std::max(max,j.max()); ++j;
205 goto nexta;
206 }
207
208 RangeList* t = range(min,max);
209 *c = t; c = &t->next;
210 }
211 for ( ; i(); ++i) {
212 RangeList* t = range(i);
213 *c = t; c = &t->next;
214 }
215 for ( ; j(); ++j) {
216 RangeList* t = range(j);
217 *c = t; c = &t->next;
218 }
219 *c = nullptr;
220 return h;
221 }
222
223 template<class I>
224 void

Callers

nothing calls this directly

Calls 7

jFunction · 0.85
rangeFunction · 0.85
iFunction · 0.70
minFunction · 0.50
maxFunction · 0.50
maxMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected