projects
/
rrq
/
rrqmisc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
documentation edits
[rrq/rrqmisc.git]
/
tests
/
example-hashvector.c
diff --git
a/tests/example-hashvector.c
b/tests/example-hashvector.c
index 63c55822fd8e4dca846a6e2da54ac81d8466cdb1..8fe73b6ad4f53397bf95e30427fec2f2bbe73ccd 100644
(file)
--- a/
tests/example-hashvector.c
+++ b/
tests/example-hashvector.c
@@
-8,18
+8,21
@@
typedef struct _ipslot {
unsigned int bits;
} 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 ) );
}
return hashvector_hashcode( key, sizeof( ipslot ) );
}
-static void* voidp_itemkey(void *item) {
+static void* voidp_itemkey(
itemkeyfun *this,
void *item) {
return 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;
}
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 ) {
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) {
}
int main(int argc,char **argv) {
+ itemkeyfun voidpfun = {
+ .hashcode = voidp_hashcode,
+ .itemkey = voidp_itemkey,
+ .haskey = voidp_haskey,
+ .releasekey = voidp_releasekey
+ };
hashvector hv = {
hashvector hv = {
- .table = { 4, 0 },
+ .table = {
1,
4, 0 },
.fill = 0,
.holes = 0,
.fill = 0,
.holes = 0,
- .keyhashcode = voidp_hashcode,
- .itemkey = voidp_itemkey,
- .haskey = voidp_haskey
+ .type = &voidpfun
};
int i = 0;
for ( ; i < 259; i++ ) {
};
int i = 0;
for ( ; i < 259; i++ ) {
@@
-54,7
+61,7
@@
int main(int argc,char **argv) {
}
for ( i = 256; i < 260; i++ ) {
vector_index index = i;
}
for ( i = 256; i < 260; i++ ) {
vector_index index = i;
- void ** slot = vector_next_used( &hv.table, &index
, 0, 0
);
+ void ** slot = vector_next_used( &hv.table, &index );
if ( slot && *slot != HV_HOLE ) {
hashvector_delete( &hv, *slot );
}
if ( slot && *slot != HV_HOLE ) {
hashvector_delete( &hv, *slot );
}