1CK_RHS_INIT(3)           BSD Library Functions Manual           CK_RHS_INIT(3)
2

NAME

4     ck_rhs_init — initialize a hash set
5

LIBRARY

7     Concurrency Kit (libck, -lck)
8

SYNOPSIS

10     #include <ck_rhs.h>
11
12     typedef unsigned long
13     ck_rhs_hash_cb_t(const void *key, unsigned long seed);
14
15     typedef bool
16     ck_rhs_compare_cb_t(const void *c1, const void *c2);
17
18     bool
19     ck_rhs_init(ck_rhs_t *hs, unsigned int mode,
20         ck_rhs_hash_cb_t *hash_function, ck_rhs_compare_cb_t *compare,
21         struct ck_malloc *allocator, unsigned long capacity,
22         unsigned long seed);
23

DESCRIPTION

25     The ck_rhs_init() function initializes the hash set pointed to by the hs
26     pointer.
27
28     The argument mode specifies the type of key-value pairs to be stored in
29     the hash set as well as the expected concurrent access model.  The value
30     of mode consists of a bitfield of one of the following:
31
32     CK_RHS_MODE_OBJECT
33             The hash set is meant to store pointers to objects. This provides
34             a hint that only CK_MD_VMA_BITS are necessary to encode the key
35             argument. Any unused pointer bits are leveraged for internal
36             optimizations.
37
38     CK_RHS_MODE_DIRECT
39             The hash set is meant to directly store key values and that all
40             bits of the key are used to encode values.
41
42     CK_RHS_MODE_READ_MOSTLY
43             Optimize read operations over put/delete.
44
45     The concurrent access model is specified by:
46
47     CK_RHS_MODE_SPMC
48             The hash set should allow for concurrent readers in the presence
49             of a single writer.
50
51     CK_RHS_MODE_MPMC
52             The hash set should allow for concurrent readers in the presence
53             of concurrent writers. This is currently unsupported.
54
55     The developer is free to specify additional workload hints.  These hints
56     are one of:
57
58The argument hash_function is a mandatory pointer to a user-specified hash
59function.  A user-specified hash function takes two arguments. The key argu‐
60ment is a pointer to a key. The seed argument is the initial seed associated
61with the hash set.  This initial seed is specified by the user in
62ck_rhs_init(3).
63
64The compare argument is an optional pointer to a user-specified key comparison
65function. If NULL is specified in this argument, then pointer equality will be
66used to determine key equality. A user-specified comparison function takes two
67arguments representing pointers to the objects being compared for equality. It
68is expected to return true if the keys are of equal value and false otherwise.
69
70The allocator argument is a pointer to a structure containing malloc and free
71function pointers which respectively define the memory allocation and destruc‐
72tion functions to be used by the hash set being initialized.
73
74The argument capacity represents the initial number of keys the hash set is
75expected to contain. This argument is simply a hint and the underlying imple‐
76mentation is free to allocate more or less memory than necessary to contain
77the number of entries capacity specifies.
78
79The argument seed specifies the initial seed used by the underlying hash func‐
80tion.  The user is free to choose a value of their choice.
81

RETURN VALUES

83     Upon successful completion ck_rhs_init() returns a value of true and oth‐
84     erwise returns a value of false to indicate an error.
85

ERRORS

87     The behavior of ck_rhs_init() is undefined if hs is not a pointer to a
88     ck_rhs_t object.
89

SEE ALSO

91     ck_rhs_move(3), ck_rhs_destroy(3), CK_RHS_HASH(3),
92     ck_rhs_iterator_init(3), ck_rhs_next(3), ck_rhs_get(3), ck_rhs_put(3),
93     ck_rhs_put_unique(3), ck_rhs_set(3), ck_rhs_fas(3), ck_rhs_remove(3),
94     ck_rhs_grow(3), ck_rhs_rebuild(3), ck_rhs_gc(3), ck_rhs_count(3),
95     ck_rhs_reset(3), ck_rhs_reset_size(3), ck_rhs_stat(3)
96
97     Additional information available at http://concurrencykit.org/
98
99                              September 17, 2012
Impressum