src/tree.c

changeset 1286
5492e8ef05f4
parent 1214
ee4e33284f0c
equal deleted inserted replaced
1285:7acbaa74fbd0 1286:5492e8ef05f4
224 cx_foreach(void *, elem, iter) { 224 cx_foreach(void *, elem, iter) {
225 // investigate the current node 225 // investigate the current node
226 int ret_elem = sfunc(elem, node); 226 int ret_elem = sfunc(elem, node);
227 if (ret_elem == 0) { 227 if (ret_elem == 0) {
228 // if found, exit the search 228 // if found, exit the search
229 *result = (void *) elem; 229 *result = elem;
230 ret = 0; 230 ret = 0;
231 break; 231 break;
232 } else if (ret_elem > 0 && ret_elem < ret) { 232 } else if (ret_elem > 0 && ret_elem < ret) {
233 // new distance is better 233 // new distance is better
234 *result = elem; 234 *result = elem;
235 ret = ret_elem; 235 ret = ret_elem;
236 } else { 236 } else if (ret_elem < 0 || ret_elem > ret) {
237 // not contained or distance is worse, skip entire subtree 237 // not contained or distance is worse, skip entire subtree
238 cxTreeIteratorContinue(iter); 238 cxTreeIteratorContinue(iter);
239 } 239 }
240 240
241 // when we reached the max depth, skip the subtree 241 // when we reached the max depth, skip the subtree

mercurial