2004-06-08 23:54:24 +00:00
|
|
|
#ifndef fooidxsethfoo
|
|
|
|
|
#define fooidxsethfoo
|
|
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
|
|
#define IDXSET_INVALID ((uint32_t) -1)
|
|
|
|
|
|
2004-06-27 22:42:17 +00:00
|
|
|
unsigned idxset_trivial_hash_func(const void *p);
|
|
|
|
|
int idxset_trivial_compare_func(const void *a, const void *b);
|
|
|
|
|
|
|
|
|
|
unsigned idxset_string_hash_func(const void *p);
|
|
|
|
|
int idxset_string_compare_func(const void *a, const void *b);
|
|
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
struct idxset;
|
|
|
|
|
|
2004-06-27 22:42:17 +00:00
|
|
|
struct idxset* idxset_new(unsigned (*hash_func) (const void *p), int (*compare_func) (const void*a, const void*b));
|
2004-06-08 23:54:24 +00:00
|
|
|
void idxset_free(struct idxset *s, void (*free_func) (void *p, void *userdata), void *userdata);
|
|
|
|
|
|
|
|
|
|
int idxset_put(struct idxset*s, void *p, uint32_t *index);
|
|
|
|
|
|
|
|
|
|
void* idxset_get_by_index(struct idxset*s, uint32_t index);
|
|
|
|
|
void* idxset_get_by_data(struct idxset*s, void *p, uint32_t *index);
|
|
|
|
|
|
|
|
|
|
void* idxset_remove_by_index(struct idxset*s, uint32_t index);
|
|
|
|
|
void* idxset_remove_by_data(struct idxset*s, void *p, uint32_t *index);
|
|
|
|
|
|
2004-06-14 20:30:50 +00:00
|
|
|
/* This may be used to iterate through all entries. When called with
|
|
|
|
|
an invalid index value it returns the first entry, otherwise the
|
|
|
|
|
next following. The function is best called with *index =
|
|
|
|
|
IDXSET_VALID first. */
|
2004-06-08 23:54:24 +00:00
|
|
|
void* idxset_rrobin(struct idxset *s, uint32_t *index);
|
|
|
|
|
|
2004-06-14 20:30:50 +00:00
|
|
|
/* Return the oldest entry in the idxset */
|
|
|
|
|
void* idxset_first(struct idxset *s, uint32_t *index);
|
2004-06-15 17:05:03 +00:00
|
|
|
void *idxset_next(struct idxset *s, uint32_t *index);
|
2004-06-14 20:30:50 +00:00
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
int idxset_foreach(struct idxset*s, int (*func)(void *p, uint32_t index, int *del, void*userdata), void *userdata);
|
|
|
|
|
|
|
|
|
|
unsigned idxset_ncontents(struct idxset*s);
|
|
|
|
|
int idxset_isempty(struct idxset *s);
|
|
|
|
|
|
2004-06-15 17:05:03 +00:00
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
#endif
|