X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=vector%2FHashVector.c;h=19269c1a0eaec61137ee12565bcf92905ee83154;hb=d6f70b77023f9682bf2c65428068a6897dd16ce3;hp=ec0e0b41a38e18aed3b4e7f48de3180a66fc4810;hpb=3d4400773c3361961bcb9f8b6898321f2005a093;p=rrq%2Frrqmisc.git diff --git a/vector/HashVector.c b/vector/HashVector.c index ec0e0b4..19269c1 100644 --- a/vector/HashVector.c +++ b/vector/HashVector.c @@ -1,8 +1,6 @@ #include #include -#define SELF hv->type - // Find the slot for the keyed element, and return pointer to it, or // to the first of holes encountered while considering collisions. // Returns a pointer to the place for the item, or 0 in case of OOM or @@ -14,9 +12,9 @@ static void **HashVector_find_slot( { if ( itemkey ) { // Get actual key from keying item - key = hv->type->itemkey( SELF, key ); + key = ItemKeyFun_itemkey( hv->type, key ); } - unsigned long index = hv->type->hashcode( SELF, key ) % hv->table.size; + unsigned long index = ItemKeyFun_hashcode( hv->type, key ) % hv->table.size; *i = index; void **hole = 0; void **p = 0; @@ -24,13 +22,13 @@ static void **HashVector_find_slot( p = Vector_entry( &hv->table, (*i) ); if ( p == 0 ) { if ( itemkey ) { - hv->type->releasekey( SELF, key ); + ItemKeyFun_releasekey( hv->type, key ); } return 0; // This basically means OOM, and is a failure condition. } if ( (*p) == 0 ) { if ( itemkey ) { - hv->type->releasekey( SELF, key ); + ItemKeyFun_releasekey( hv->type, key ); } return ( hole )? hole : p; // Not found; it's place is here. } @@ -38,9 +36,9 @@ static void **HashVector_find_slot( if ( hole == 0 ) { hole = p; // Remember the first hole } - } else if ( hv->type->haskey( SELF, (*p), key ) ) { + } else if ( ItemKeyFun_haskey( hv->type, (*p), key ) ) { if ( itemkey ) { - hv->type->releasekey( SELF, key ); + ItemKeyFun_releasekey( hv->type, key ); } return p; // Found } @@ -49,7 +47,7 @@ static void **HashVector_find_slot( } if ( (*i) == index ) { if ( itemkey ) { - hv->type->releasekey( SELF, key ); + ItemKeyFun_releasekey( hv->type, key ); } return 0; // Overfull HashVector! } @@ -59,7 +57,7 @@ static void **HashVector_find_slot( // Find the keyed item void *HashVector_find(HashVector *hv,void *key) { VectorIndex index = 0; - void **slot = HashVector_find_slot( hv, &index, key, 0 ); + void **slot = HashVector_find_slot( hv, key, &index, 0 ); return ( slot && *slot && *slot != HV_HOLE )? *slot : 0; } @@ -80,6 +78,7 @@ void *HashVector_next(HashVector *hv,VectorIndex *index) { } static int capture_item(Vector *pv,unsigned long ix,void *item,void *data) { + (void)pv; (void)ix; if ( item && item != HV_HOLE ) { HashVector_add( (HashVector *) data, item ); } @@ -87,6 +86,7 @@ static int capture_item(Vector *pv,unsigned long ix,void *item,void *data) { } static int iter_item(unsigned long ix,void *item,void *data) { + (void)ix; if ( item && item != HV_HOLE ) { HashVector_add( (HashVector *) data, item ); }