12ec1aca4f2eff7190335c6ab647af82864b9104
[rrq/rrqmisc.git] / vector / stringitem.c
1 #include <string.h>
2 #include <stringitem.h>
3 #include <hashvector.h>
4
5 unsigned long integeritem_hashcode(itemkeyfun *this,void *key) {
6     return hashvector_hashcode( (unsigned char*)key, strlen( (char*)key ) );
7 }
8
9 /**
10  * This callback function determines whether an item has a
11  * given key or not.
12  */
13 int integeritem_haskey(itemkeyfun *this,void *item,void *key) {
14     return strcmp( item, key ) == 0;
15 }
16
17 /**
18  * This callback function returns the key of an item by considering
19  * the arity and schema.
20  */
21 void *integeritem_itemkey(itemkeyfun *this,void *item) {
22     return item;
23 }
24
25 /**
26  * This callback function handles a key obtained from the itemkey
27  * callback function to reclaim temporary allocation.
28  */
29 void integeritem_releasekey(itemkeyfun *this,void *key) {
30 }
31
32 itemkeyfun stringitem = {
33     .hashcode = stringitem_hashcode,
34     .haskey = stringitem_haskey,
35     .itemkey = stringitem_itemkey,
36     .releasekey = stringitem_releasekey
37 };
38
39