Changeset 740 for vendor/current/lib/util/binsearch.h
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/util/binsearch.h
r414 r740 66 66 }} } while (0) 67 67 68 /* 69 like BINARY_ARRAY_SEARCH_P, but assumes that the array is an array 70 of elements, rather than pointers to structures 71 72 result points to the found structure, or NULL 73 */ 74 #define BINARY_ARRAY_SEARCH_V(array, array_size, target, comparison_fn, result) do { \ 75 int32_t _b, _e; \ 76 (result) = NULL; \ 77 if (array_size) { for (_b = 0, _e = (array_size)-1; _b <= _e; ) { \ 78 int32_t _i = (_b+_e)/2; \ 79 int _r = comparison_fn(target, array[_i]); \ 80 if (_r == 0) { (result) = &array[_i]; break; } \ 81 if (_r < 0) _e = _i - 1; else _b = _i + 1; \ 82 }} } while (0) 83 68 84 #endif
Note:
See TracChangeset
for help on using the changeset viewer.