dhash_example.c revision 4fdcab8ba579b481870d5a6a422fcca70712d30f
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "dhash.h"
struct my_data_t {
int foo;
char bar[128];
};
{
}
{
(*count)++;
return true;
}
{
return my_data;
}
{
struct hash_iter_context_t *iter;
unsigned long i, n_entries;
int error;
unsigned long count;
/* Create a hash table */
if (error != HASH_SUCCESS) {
return error;
}
/* Enter a key named "My Data" and specify it's value as a pointer to my_data */
return error;
}
/* Get a list of keys and print them out, free the list when we're done */
return error;
}
for (i = 0; i < count; i++)
/* Lookup the key named "My Data" */
}
/* Visit each entry in the table, callback will increment count on each visit */
printf("Iterate using callback\n");
count = 0;
/* Assure number of visits equal the table size */
/* Visit each entry using iterator object */
printf("Iterate using iterator\n");
n_entries = 0;
n_entries++;
}
/* Assure number of visits equal the table size */
/* Remove the entry, deletion callback will be invoked */
}
/* Assure key is no longer in table */
/* Free the table */
return 0;
}