Diffusion C API
6.7.9
|
A simple set implementation, based on hash.h. More...
Data Structures | |
struct | set_entry_s |
This structure represents an entry in the set. More... | |
struct | set_s |
This respresents a set. More... | |
Typedefs | |
typedef struct set_entry_s | SET_ENTRY_T |
This structure represents an entry in the set. | |
typedef struct set_s | SET_T |
This respresents a set. | |
Functions | |
SET_T * | set_new (const unsigned long slots) |
Create a new set with the given number of slots. More... | |
SET_T * | set_new_string (const unsigned long slots) |
Create a new set which holds strings (pointers to char). | |
SET_T * | set_new_int (const unsigned long slots) |
Create a new set which holds pointers to integers. | |
void * | set_add_int (SET_T *set, const int val) |
Helper to add integers to sets. | |
void | set_free (SET_T *set) |
Frees memory (including values) associated with a set. More... | |
void * | set_add (SET_T *set, const void *val) |
Add a value to a set. More... | |
void * | set_del (SET_T *set, const void *val) |
Remove a value from the set. More... | |
void * | set_contains (const SET_T *set, const void *val) |
Test whether a set contains a given value. More... | |
void ** | set_values (const SET_T *set) |
Obtains all values currently in the set. More... | |
SET_T * | set_dup (const SET_T *set) |
Create a deep copy of a set. More... | |
A simple set implementation, based on hash.h.
Copyright © 2014, 2021 Push Technology Ltd., All Rights Reserved.
Use is subject to license terms.
NOTICE: All information contained herein is, and remains the property of Push Technology. The intellectual and technical concepts contained herein are proprietary to Push Technology and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law.
void* set_add | ( | SET_T * | set, |
const void * | val | ||
) |
Add a value to a set.
If the set already contains the value, a pointer to the value in the set is returned.
set | The set to which the value will be added. |
val | The value to store. |
void * | If the value already exists in the set. |
NULL | If the value did not already exist in the set. |
void* set_contains | ( | const SET_T * | set, |
const void * | val | ||
) |
Test whether a set contains a given value.
set | The set to be searched for the value. |
val | The value which is to be searched for. |
void * | The value, if found. |
NULL | If the value was not found. |
void* set_del | ( | SET_T * | set, |
const void * | val | ||
) |
Remove a value from the set.
set | The set from which the value will be removed. |
val | The value to be removed from the set. |
void * | The value which was removed. The caller should free this value. |
NULL | If the value was not found. |
Create a deep copy of a set.
set_free
should be called on the pointer when no longer needed.
set | The set to copy. |
void set_free | ( | SET_T * | set | ) |
Frees memory (including values) associated with a set.
This function can free all memory associated with a set.
set | The set to be freed. |
SET_T* set_new | ( | const unsigned long | slots | ) |
Create a new set with the given number of slots.
slots | The number of slots available in the set. Values hash to a slot, and if a slot already contains a value which yields the same hash, it is chained to other entries in the bucket. |
SET_T * | Returns a pointer to a SET_T structure. |
NULL | If the set cannot be created. |
void** set_values | ( | const SET_T * | set | ) |
Obtains all values currently in the set.
set | The set to be inspected. |