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

Method range

gecode/int/extensional/compact.hpp:115–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113 */
114 template<class View, bool pos>
115 const typename Compact<View,pos>::Range*
116 Compact<View,pos>::range(CTAdvisor& a, int n) {
117 assert((n > a.fst()->max) && (n < a.lst()->min));
118
119 const Range* f=a.fst()+1;
120 const Range* l=a.lst()-1;
121
122 assert(!pos || (f<=l));
123
124 while (f < l) {
125 const Range* m = f + ((l-f) >> 1);
126 if (n < m->min) {
127 l=m-1;
128 } else if (n > m->max) {
129 f=m+1;
130 } else {
131 f=m; break;
132 }
133 }
134
135 if (pos) {
136 assert((f->min <= n) && (n <= f->max));
137 return f;
138 } else {
139 if ((f <= l) && (f->min <= n) && (n <= f->max))
140 return f;
141 else
142 return nullptr;
143 }
144 }
145
146 template<class View, bool pos>
147 forceinline const BitSetData*

Callers

nothing calls this directly

Calls 2

fstMethod · 0.45
lstMethod · 0.45

Tested by

no test coverage detected