Skip to content

Commit

Permalink
test removing bsearch function
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGAzed committed Dec 29, 2024
1 parent ee3b04b commit 1df5516
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions headers/binary_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,6 @@ static inline void destroy_binary_set(binary_set_s * set, const destroy_binary_s
}

static inline bool contains_binary_set(const binary_set_s set, const BINARY_SET_DATA_TYPE element) {
if (set.compare) { // uses buildin binary search implmentation if compare function is specified
return bsearch(&element, set.elements, set.size, sizeof(BINARY_SET_DATA_TYPE), set.compare) != NULL;
}
// else custom binary search is used as memcmp takes three arguments as input
// (bsearch requires a 2 argument compare function). IF ONLY NESTED FUNCTION WERE PART OF THE C STANDARD.

BINARY_SET_DATA_TYPE * base = set.elements;
for (size_t limit = set.size; limit != 0; limit >>= 1) {
BINARY_SET_DATA_TYPE * current_element = base + (limit >> 1);
Expand Down

0 comments on commit 1df5516

Please sign in to comment.