Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Red Black Tree: Provide extra function to override compare(cmp) function #3

Merged
merged 2 commits into from
Dec 8, 2020

Conversation

recp
Copy link
Owner

@recp recp commented Dec 5, 2020

New functions:

void*   rb_find_by(RBTree * __restrict tree, void * __restrict key, const DsCmpFn cmp);
RBNode* rb_find_node_by(RBTree * __restrict tree, void * __restrict key, const DsCmpFn cmp);

Custom compare can be used for getting items. For instance you can compare null terminated string with non-null terminated string by providing custom compare to rb_find_by().

  • previous rb_find() and rb_find_node() now uses rb_find_node_by() to reduce pointer dereferencing (hope there will no bugs here)

in this way, custom compare can be used for getting items. For instance you can compare null terminated string with non-null terminated string by providing custom compare to find()
@recp recp merged commit ad33882 into master Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant