Defines | Functions

sst/elements/genericProc/programs/libcprops/hashlist.c File Reference

Implementation for cp_hashlist Collection with linked elements and hash key and with cp_hashlist_iterator. More...

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "collection.h"
#include "log.h"
#include "common.h"
#include "hashlist.h"
#include "linked_list.h"
#include "config.h"

Defines

#define CP_HASHLIST_MULTIPLE_VALUES   1

Functions

int cp_hashlist_txlock (cp_hashlist *list, int type)
int cp_hashlist_txunlock (cp_hashlist *list)
static cp_hashlist_entry * cp_hashlist_create_entry (cp_hashlist *list, int mode, void *key, void *value)
static void cp_hashlist_entry_delete (cp_hashlist_entry *entry)
static void cp_hashlist_entry_release_by_option (cp_hashlist *list, cp_hashlist_entry *entry, int mode)
static cp_hashlist_entry * cp_hashlist_insert_internal (cp_hashlist *list, cp_hashlist_entry *entry)
 insert an entry
static cp_hashlist_entry * cp_hashlist_remove_internal (cp_hashlist *list, void *key)
 remove first entry matching key
static cp_hashlist_entry * cp_hashlist_remove_entry_internal (cp_hashlist *list, cp_hashlist_entry *entry)
 remove specified entry
static void * cp_hashlist_get_internal (cp_hashlist *list, void *key)
cp_hashlistcp_hashlist_create_by_option (int mode, unsigned long size_hint, cp_hashfunction hash_fn, cp_compare_fn compare_fn, cp_copy_fn copy_key, cp_destructor_fn free_key, cp_copy_fn copy_value, cp_destructor_fn free_value)
 Constructor for copy mode.
cp_hashlistcp_hashlist_create_by_mode (int mode, unsigned long size_hint, cp_hashfunction hash_fn, cp_compare_fn compare_fn)
 constructor with parameters.
static void cp_hashlist_destroy_internal (cp_hashlist *list, int mode, cp_destructor_fn dk, cp_destructor_fn dv)
void cp_hashlist_destroy (cp_hashlist *list)
 Destroy the list with the mode stored in the list.
void cp_hashlist_destroy_deep (cp_hashlist *list)
 Destroy the list with the mode stored in the list plus COLLECTION_MODE_DEEP.
void cp_hashlist_destroy_by_option (cp_hashlist *list, int mode)
 Destroy the object with the specified mode (override default).
void cp_hashlist_destroy_custom (cp_hashlist *list, cp_destructor_fn dk, cp_destructor_fn dv)
 This function does exactly what you would think it does.
int cp_hashlist_callback (cp_hashlist *list, int(*cb)(void *key, void *value, void *id), void *id)
 iterates over the list and calls the callback function on each item.
int cp_hashlist_get_mode (cp_hashlist *list)
 find out what mode your cp_hashlist is running in
int cp_hashlist_set_mode (cp_hashlist *list, int mode)
 set the mode on your cp_hashlist
int cp_hashlist_unset_mode (cp_hashlist *list, int mode)
 unset mode bits on list
int cp_hashlist_set_min_size (cp_hashlist *list, unsigned long min_size)
 the internal table will not be resized to less than min_size
int cp_hashlist_set_max_fill_factor (cp_hashlist *list, int fill_factor)
 a resize is triggered when the table contains more items than table_size * fill_factor / 100
int cp_hashlist_set_min_fill_factor (cp_hashlist *list, int fill_factor)
 a resize is triggered when the table contains less items than table_size * fill_factor / 100 if table_size > min_size
void * cp_hashlist_resize_nosync (cp_hashlist *list, unsigned long new_size)
void * cp_hashlist_append (cp_hashlist *list, void *key, void *value)
 Append a new element (key, value) at the end of the list.
static int cp_hashlist_contains_internal (cp_hashlist *list, void *key)
int cp_hashlist_contains (cp_hashlist *list, void *key)
 returns non-zero if list contains key
void * cp_hashlist_append_by_option (cp_hashlist *list, void *key, void *value, int mode)
 Append a new element (key, value) at the end of the list with mode.
void * cp_hashlist_insert (cp_hashlist *list, void *key, void *value)
 Insert a new element (key, value) at the beginning of the list.
void * cp_hashlist_insert_by_option (cp_hashlist *list, void *key, void *value, int mode)
 Insert a new element (key, value) at the beginning of the list with mode.
void * cp_hashlist_get (cp_hashlist *list, void *key)
 Returns the first element with matching key.
static void * cp_hashlist_unlink_internal (cp_hashlist *list, cp_hashlist_entry *holder, int mode)
void * cp_hashlist_remove (cp_hashlist *list, void *key)
 Removes the entry with matching key and destroys it (internal locking mode).
void * cp_hashlist_remove_deep (cp_hashlist *list, void *key)
void * cp_hashlist_get_head (cp_hashlist *list)
 Returns the first element of the list.
void * cp_hashlist_get_tail (cp_hashlist *list)
 Returns the last element of the list.
void * cp_hashlist_remove_head (cp_hashlist *list)
 Removes the first entry and destroys it.
void * cp_hashlist_remove_head_by_option (cp_hashlist *list, int mode)
 Removes the first entry and destroys it.
void * cp_hashlist_remove_tail (cp_hashlist *list)
 Removes the last entry and destroys it.
void * cp_hashlist_remove_tail_by_option (cp_hashlist *list, int mode)
 Removes the last entry and destroys it.
unsigned long cp_hashlist_item_count (cp_hashlist *list)
 Get the number of elements in the collection.
int cp_hashlist_lock_internal (cp_hashlist *list, int lock_mode)
int cp_hashlist_unlock_internal (cp_hashlist *list)
int cp_hashlist_lock (cp_hashlist *list, int type)
 Locks the collection with the specified mode.
int cp_hashlist_unlock (cp_hashlist *list)
 Unlock the object.
void * cp_hashlist_entry_get_key (cp_hashlist_entry *entry)
 Get the key of the entry.
void * cp_hashlist_entry_get_value (cp_hashlist_entry *entry)
 Get the value of the entry.
int cp_hashlist_is_empty (cp_hashlist *list)
 Test if object is empty.
cp_hashlist_iteratorcp_hashlist_create_iterator (cp_hashlist *list, int type)
 Create a new iterator and initialize it at the beginning.
int cp_hashlist_iterator_init (cp_hashlist_iterator *iterator, cp_hashlist *list, int type)
int cp_hashlist_iterator_head (cp_hashlist_iterator *iterator)
 initialize the iterator at the beginning
int cp_hashlist_iterator_tail (cp_hashlist_iterator *iterator)
 set iterator at list tail
int cp_hashlist_iterator_init_tail (cp_hashlist_iterator *iterator, cp_hashlist *list, int type)
 Initialize the Iterator at the end.
int cp_hashlist_iterator_to_key (cp_hashlist_iterator *iterator, void *key)
 set iterator position at first occurence of given key
int cp_hashlist_iterator_release (cp_hashlist_iterator *iterator)
 Unlock the list of the Iterator.
int cp_hashlist_iterator_destroy (cp_hashlist_iterator *iterator)
 iterator destructor
cp_hashlist_entry * cp_hashlist_iterator_next (cp_hashlist_iterator *iterator)
 Go to the next entry in the list and return the content.
void * cp_hashlist_iterator_next_key (cp_hashlist_iterator *iterator)
 Go to the next entry in the list and return the key.
void * cp_hashlist_iterator_next_value (cp_hashlist_iterator *iterator)
 Go to the next entry in the list and return the content.
cp_hashlist_entry * cp_hashlist_iterator_prev (cp_hashlist_iterator *iterator)
 Go to the previous entry in the list and return the content.
void * cp_hashlist_iterator_prev_key (cp_hashlist_iterator *iterator)
 Go to the previous entry in the list and return the key.
void * cp_hashlist_iterator_prev_value (cp_hashlist_iterator *iterator)
 Go to the previous entry in the list and return the content.
cp_hashlist_entry * cp_hashlist_iterator_curr (cp_hashlist_iterator *iterator)
 return the entry at the current iterator position
void * cp_hashlist_iterator_curr_key (cp_hashlist_iterator *iterator)
 return the key at the current iterator position
void * cp_hashlist_iterator_curr_value (cp_hashlist_iterator *iterator)
 return the value at the current iterator position
cp_hashlist_entry * cp_hashlist_iterator_insert (cp_hashlist_iterator *iterator, void *key, void *value)
 add a mapping before the current iterator position
cp_hashlist_entry * cp_hashlist_iterator_append (cp_hashlist_iterator *iterator, void *key, void *value)
 add a mapping after the current iterator position
void * cp_hashlist_iterator_remove (cp_hashlist_iterator *iterator)
 remove the mapping at the current iterator position

void * cp_hashlist_remove_by_option (cp_hashlist *list, void *key, int mode)
 Removes the entry with matching key and destroys it with locking mode.

Detailed Description

Implementation for cp_hashlist Collection with linked elements and hash key and with cp_hashlist_iterator.