cp_hashtable_put(3)
| cp_hashtable(3) | libcprops - cp_hashtable | cp_hashtable(3) |
NAME
cp_hashtable_put, cp_hashtable_put_by_option, cp_hashtable_put_safe, cp_hashtable_put_copy - add an entry to a hashtable
SYNOPSIS
#include <cprops/hashtable.h>
void *cp_hashtable_put(cp_hashtable *table, void
*key, void *value);
void *cp_hashtable_put_by_option(cp_hashtable *table, void
*key, void *value, int
mode);
void *cp_hashtable_put_safe(cp_hashtable *table, void *
key, void *value);
void *cp_hashtable_put_copy(cp_hashtable *table, void
*key, void *value);
DESCRIPTION
cp_hashtable_put adds a mapping from key to value using the current mode on table. The effect of various mode bits is as follows:
- COLLECTION_MODE_DEEP - if a mapping for key already exists, the
- destructor functions are called on the existing key and value and they are replaced with the new settings - unless COLLECTION_MODE_MULTIPLE_VALUES is set.
- COLLECTION_MODE_MULTIPLE_VALUES - allows multiple mappings for a given
- key.
- COLLECTION_MODE_COPY - the copy functions specified on table creation
- are used to store copies of the key and value.
- COLLECTION_MODE_NOSYNC - no locking is performed on insertion.
- COLLECTION_MODE_NORESIZE - a resize will not be triggered even if the
- fill factor exceeds the maximum setting for the table.
cp_hashtable_put_by_option allows specifying a mode setting overriding the current table mode, with the exception that the COLLECTION_MODE_NOSYNC bit on the option parameter has no effect.
cp_hashtable_put_safe has the effect of an insertion with the COLLECTION_MODE_DEEP bit set. cp_hashtable_put_copy has the effect of an insertion with the COLLECTION_MODE_COPY bit set.
RETURN VALUE
insertion functions return a pointer to the actual inserted value, which may be different to the value parameter if COLLECTION_MODE_COPY is set, or NULL if the insertion failed.
ERRORS
- ENOMEM - an internal allocation failed.
SEE ALSO
cp_hashtable(3), cp_hashtable_get(3), cp_hashtable_set_mode(3), cp_hashtable_set_max_fill_factor(3)
| OCTOBER 2005 | libcprops.0.0.3 |
