X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=vector%2Fhashvector.h;h=a4f9f7f1676034e86ef4f127b68db4fbbc8cda30;hb=c94b62d99f7e3a9ef61ab5cf0f4d7a874e8d2dd4;hp=d0f9e12f23114f0ec5aecac85c289e9641d49c85;hpb=c1aae73b1fafd372c4f38a1a205e20a9f22a2fa0;p=rrq%2Frrqmisc.git diff --git a/vector/hashvector.h b/vector/hashvector.h index d0f9e12..a4f9f7f 100644 --- a/vector/hashvector.h +++ b/vector/hashvector.h @@ -32,6 +32,7 @@ * hashvector combines a vector (for contents) with fill and hole * counters, and itemkeyfun callback functions for abstracting items * as being pairs of key and payload. + * \extends vector */ typedef struct { /** @@ -71,13 +72,15 @@ typedef struct { #define HV_HOLE ((void*) 1) /** - * Find the item, if any, with the given key and assign *x with its - * address. Returns 1 on success and 0 on failure to find the keyed - * item. Note that when the function returns 0, *x is unchanged. + * \brief Find next keyed item at or after the given index. + * \param hv is the hasvector concerned + * \param index is a pointer to the index to advance + * \param key is the query key + * \returns the next matching item, or 0 if none, with the index updated. * * \related hashvector */ -int hashvector_find(hashvector *hv,void *key,void **x); +extern void *hashvector_next(hashvector *hv,vector_index *i,void *key); /** * Add the given item into the hashvector, growing the hashvector as @@ -89,7 +92,7 @@ int hashvector_find(hashvector *hv,void *key,void **x); * * \related hashvector */ -int hashvector_add(hashvector *hv,void *item); +extern int hashvector_add(hashvector *hv,void *item); /** * Delete the given item, and shrink the hashvector so that its size @@ -100,7 +103,7 @@ int hashvector_add(hashvector *hv,void *item); * * \related hashvector */ -int hashvector_delete(hashvector *hv,void *item); +extern int hashvector_delete(hashvector *hv,void *item); /** * Copy content items into a vector, which must be empty. The @@ -111,7 +114,7 @@ int hashvector_delete(hashvector *hv,void *item); * * \related hashvector */ -int hashvector_contents(hashvector *hv,vector *pv); +extern int hashvector_contents(hashvector *hv,vector *pv); /** * This is a utility function to compute and return a hashcode for a @@ -119,6 +122,12 @@ int hashvector_contents(hashvector *hv,vector *pv); * * \related hashvector */ -unsigned long hashvector_hashcode(unsigned char *key,unsigned long n); +extern unsigned long hashvector_hashcode(unsigned char *key,unsigned long n); + +/** + * Create a hashvector for of given variant for given itemkeyfun* + */ +extern hashvector *hashvector_create( + enum vector_variant variant,itemkeyfun *type); #endif