#include <stdlib.h>
Go to the source code of this file.
|
hashset_t | hashset_create (unsigned short nbits) |
| Create a hashset instance. The returned value is a pointer. The caller must call hashset_destroy() to free allocated memory.
|
|
void | hashset_destroy (hashset_t set) |
| Destroy the hashset instance, freeing allocated memory.
|
|
size_t | hashset_num_items (hashset_t set) |
| Return the number of items in the hashset.
|
|
int | hashset_add (hashset_t set, void *item) |
| Add a pointer to the hashset. Note that 0 and 1 are special values, meaning nil and deleted items. This function will return -1 indicating error if you try to add 0 or 1. This function may resize the hashset if it is approaching capacity. Returns zero if the item is already in the set and non-zero otherwise.
|
|
int | hashset_remove (hashset_t set, void *item) |
| Remove an item from the hashset. Return non-zero if the item was removed and zero if the item is not on the hashset.
|
|
int | hashset_is_member (hashset_t set, void *item) |
| Returns non-zero if the item is in the hashset and zero otherwise.
|
|
◆ hashset_t
◆ hashset_add()
int hashset_add |
( |
hashset_t | set, |
|
|
void * | item ) |
Add a pointer to the hashset. Note that 0 and 1 are special values, meaning nil and deleted items. This function will return -1 indicating error if you try to add 0 or 1. This function may resize the hashset if it is approaching capacity. Returns zero if the item is already in the set and non-zero otherwise.
◆ hashset_create()
hashset_t hashset_create |
( |
unsigned short | nbits | ) |
|
Create a hashset instance. The returned value is a pointer. The caller must call hashset_destroy() to free allocated memory.
- Parameters
-
nbits | The log base 2 of the initial capacity of the hashset. |
◆ hashset_destroy()
Destroy the hashset instance, freeing allocated memory.
◆ hashset_is_member()
int hashset_is_member |
( |
hashset_t | set, |
|
|
void * | item ) |
Returns non-zero if the item is in the hashset and zero otherwise.
◆ hashset_num_items()
Return the number of items in the hashset.
◆ hashset_remove()
int hashset_remove |
( |
hashset_t | set, |
|
|
void * | item ) |
Remove an item from the hashset. Return non-zero if the item was removed and zero if the item is not on the hashset.