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

modifying key interface requirements #12

Open
fancong5201314 opened this issue Jan 26, 2022 · 4 comments
Open

modifying key interface requirements #12

fancong5201314 opened this issue Jan 26, 2022 · 4 comments

Comments

@fancong5201314
Copy link

Can you provide an interface "hashmap_set" for modifying the key, the function is to add the key if it does not exist, and modify it if it exists. Thank you so much.

@DavidLeeds
Copy link
Owner

Hi @fancong5201314,

Would this satisfy your needs?

int hashmap_base_update(struct hashmap_base *hb, const void *key, void *data, void **original_data);

This would be used like this:

int r;
struct my_data *new_data = /* new data */;
struct my_data *old_data;

r = hashmap_update(&my_map, "MyKey", new_data, &old_data);
if (r < 0) {
    // Error
}

free(old_data);

@fancong5201314
Copy link
Author

I'll try it first, thanks.

@fancong5201314
Copy link
Author

Where are the two functions hashmap_update and hashmap_base_update implemented?

@fancong5201314
Copy link
Author

I use this to replace the redundant map table of C++. Now hashmap supports adding, deleting, and querying, but it has not been modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants