X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=tests%2Fexample-hashvector.c;h=8fe73b6ad4f53397bf95e30427fec2f2bbe73ccd;hb=c08a0975036f23f972a16a07efb0c07113c96d2e;hp=7bd57a5f53a3018aa7a101b501553d64db30919b;hpb=a0be49ff8fda77c328424c09d6d0ad4a9f7e8f66;p=rrq%2Frrqmisc.git diff --git a/tests/example-hashvector.c b/tests/example-hashvector.c index 7bd57a5..8fe73b6 100644 --- a/tests/example-hashvector.c +++ b/tests/example-hashvector.c @@ -8,18 +8,21 @@ typedef struct _ipslot { unsigned int bits; } ipslot; -static unsigned long voidp_hashcode(void *key) { +static unsigned long voidp_hashcode(itemkeyfun *this,void *key) { return hashvector_hashcode( key, sizeof( ipslot ) ); } -static void* voidp_itemkey(void *item) { +static void* voidp_itemkey(itemkeyfun *this,void *item) { return item; } -static int voidp_haskey(void *item,void *key) { +static int voidp_haskey(itemkeyfun *this,void *item,void *key) { return memcmp( item, key, sizeof( ipslot ) ) == 0; } +static void voidp_releasekey(itemkeyfun *this,void *key) { +} + static int shrink(vector *pv,unsigned long index,void *item,void *data) { if ( item ) { if ( item == HV_HOLE ) { @@ -33,13 +36,17 @@ static int shrink(vector *pv,unsigned long index,void *item,void *data) { } int main(int argc,char **argv) { + itemkeyfun voidpfun = { + .hashcode = voidp_hashcode, + .itemkey = voidp_itemkey, + .haskey = voidp_haskey, + .releasekey = voidp_releasekey + }; hashvector hv = { - .table = { 4, 0 }, + .table = { 1, 4, 0 }, .fill = 0, .holes = 0, - .keyhashcode = voidp_hashcode, - .itemkey = voidp_itemkey, - .haskey = voidp_haskey + .type = &voidpfun }; int i = 0; for ( ; i < 259; i++ ) {