#include <stdlib.h>
#include <string.h>
-#include "hashvector.h"
+#include "HashVector.h"
typedef struct _ipslot {
int family;
} ipslot;
static unsigned long voidp_hashcode(void *this,void *key) {
- return hashvector_hashcode( key, sizeof( ipslot ) );
+ return HashVector_hashcode( key, sizeof( ipslot ) );
}
static void* voidp_itemkey(void *this,void *item) {
return snprintf( buffer, limit, "%p", item );
}
-static int shrink(vector *pv,unsigned long index,void *item,void *data) {
+static int shrink(Vector *pv,unsigned long index,void *item,void *data) {
if ( item ) {
if ( item == HV_HOLE ) {
- ((hashvector*) data)->holes--;
+ ((HashVector*) data)->holes--;
} else {
free( item );
- ((hashvector*) data)->fill--;
+ ((HashVector*) data)->fill--;
}
}
return 0;
}
int main(int argc,char **argv) {
- itemkeyfun voidpfun = {
+ ItemKeyFun voidpfun = {
.hashcode = voidp_hashcode,
.itemkey = voidp_itemkey,
.haskey = voidp_haskey,
.releasekey = voidp_releasekey,
.tostring = voidp_tostring
};
- hashvector hv = {
+ HashVector hv = {
.table = { 1, 4, 0 },
.fill = 0,
.holes = 0,
}
item->family = i;
memcpy( item->data, "10.10.10.1", 10 );
- hashvector_add( &hv, item );
+ HashVector_add( &hv, item );
}
for ( i = 256; i < 260; i++ ) {
- vector_index index = i;
- void ** slot = vector_next_used( &hv.table, &index );
+ VectorIndex index = i;
+ void ** slot = Vector_next_used( &hv.table, &index );
if ( slot && *slot != HV_HOLE ) {
- hashvector_delete( &hv, *slot );
+ HashVector_delete( &hv, *slot );
}
}
- vector_resize( &hv.table, 256, shrink, &hv );
+ Vector_resize( &hv.table, 256, shrink, &hv );
return 0;
}