forked from concurrencykit/ck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ck_hs: Allow specifying an offset to embedded keys
A common use case for hash sets is to store objects in a hash sets keyed on some embedded key within the object. The current interface requires the client to write hash and comparator functions that are specific to each object type being inserted into the hash. Alternatively, the client may store pointers to the keys in the hash set and use `container_of` to recover the actual object value. This is also quite cumbersome. This patch adds a function `ck_hs_init_from_options` that initializes a hash set from an extensible struct of options. The struct contains all the information currently passed to `ck_hs_init`, and also allows specifying a short 15 bit key offset when the hash set uses `CK_HS_MODE_OBJECT` mode. The patch sets the following invariants: - The public interface always specifies whether a parameter pointer is to a key or a value. - Hash and comparator functions are always called on pointers to keys. Fixes concurrencykit#152
- Loading branch information
1 parent
4adf131
commit 9757231
Showing
5 changed files
with
516 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.