Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

collection.h File Reference

#include "common.h"
#include "log.h"

Go to the source code of this file.

Data Structures

struct  _cp_mapping
struct  _cp_index
struct  _cp_wrap


Detailed Description

The c collection classes provide plain c implementations of famous data structures and algorithms such as linked lists, hash tables, hash lists and an extensible tree implementation (see graph.h). Behavior in terms of synchronization and member uniqueness may be set on initialization using the appropriate constructor function with the required flags. The default implementations are synchronized, and mostly allow mutliple values with the notable exception of the cp_hashtable and cp_hashlist collections which do not by default. Other subtle differences deriving from data structure characteristics or implementation inconsistencies would suggest reading the inline documentation in the header files for the specific collection you intend to use.

This header file defines macros and function types used commonly throughout the package.

Definition in file collection.h.


Define Documentation

#define COLLECTION_LOCK_NONE   0
 

no lock

Definition at line 69 of file collection.h.

Referenced by cp_socket_delete().

#define COLLECTION_LOCK_READ   1
 

lock for reading

Definition at line 71 of file collection.h.

Referenced by cp_hashlist_callback(), cp_hashlist_contains(), cp_hashlist_create_iterator(), cp_hashlist_get(), cp_hashlist_item_count(), cp_hashlist_iterator_init_tail(), cp_hashtable_contains(), cp_hashtable_get_by_option(), cp_hashtable_get_keys(), cp_hashtable_get_values(), cp_list_callback(), cp_list_is_empty(), cp_list_search(), cp_priority_list_is_empty(), cp_socket_stop_all(), cp_thread_pool_stop(), cp_trie_exact_match(), cp_trie_fetch_matches(), cp_trie_prefix_match(), cp_trie_remove(), and cp_trie_submatch().

#define COLLECTION_LOCK_WRITE   2
 

lock for writing

Definition at line 73 of file collection.h.

Referenced by cp_hashlist_append_by_option(), cp_hashlist_create_iterator(), cp_hashlist_get_head(), cp_hashlist_get_tail(), cp_hashlist_insert_by_option(), cp_hashlist_iterator_init_tail(), cp_hashlist_remove_by_option(), cp_hashlist_remove_head_by_option(), cp_hashlist_remove_tail_by_option(), cp_hashlist_set_max_fill_factor(), cp_hashlist_set_min_fill_factor(), cp_hashlist_set_min_size(), cp_hashlist_set_mode(), cp_hashlist_unset_mode(), cp_hashtable_put_by_option(), cp_hashtable_remove_all(), cp_hashtable_remove_by_mode(), cp_hashtable_resize_thread(), cp_hashtable_set_max_fill_factor(), cp_hashtable_set_min_fill_factor(), cp_hashtable_set_min_size(), cp_hashtable_set_mode(), cp_hashtable_unset_mode(), cp_list_append(), cp_list_get_head(), cp_list_get_tail(), cp_list_insert(), cp_list_insert_after(), cp_list_insert_before(), cp_list_remove(), cp_list_remove_head(), cp_list_remove_tail(), cp_priority_list_get_next_by_option(), cp_priority_list_insert_by_option(), and cp_trie_add().

#define COLLECTION_MODE_COPY   4
 

collection stores copies of elements (keys, values)

Definition at line 46 of file collection.h.

Referenced by cp_hashtable_create_copy_mode(), cp_hashtable_put_copy(), cp_http_response_create(), and cp_httpclient_set_parameter().

#define COLLECTION_MODE_DEEP   1
 

collection copies and deletes elements (keys, values)

Definition at line 42 of file collection.h.

Referenced by cp_hashlist_destroy_deep(), cp_hashtable_create_copy_mode(), cp_hashtable_destroy_deep(), cp_hashtable_destroy_shallow(), cp_hashtable_put_safe(), cp_hashtable_remove_deep(), cp_http_init(), cp_http_response_create(), cp_httpclient_init(), cp_httpclient_set_parameter(), cp_httpsocket_register_service(), cp_list_destroy_custom(), cp_list_iterator_remove(), cp_socket_create(), and cp_socket_init().

#define COLLECTION_MODE_IN_TRANSACTION   64
 

indicates a transaction is in progress

Definition at line 66 of file collection.h.

#define COLLECTION_MODE_LIST_ORDER   32
 

hashlist multiple values are returned in list order (O(N)) rather than insertion order (O(1))

Definition at line 62 of file collection.h.

#define COLLECTION_MODE_MULTIPLE_VALUES   2
 

collection allows non-unique keys

Definition at line 44 of file collection.h.

Referenced by cp_db_connection_pool_create(), and cp_list_create().

#define COLLECTION_MODE_NORESIZE   16
 

The collection does not resize underlying hashtables. It might make sense to set this temporarily in code sections that shouldn't be unexpectedly slowed down by a resize operation, but resize should be allowed if the table fill factor is expected to go over ~70%, which is the point at which hashtable performace is rumored to start degrading.

Definition at line 57 of file collection.h.

#define COLLECTION_MODE_NOSYNC   8
 

no synchronization - suitable for the single threaded situation or if you want to do the synchronization yourself.

Definition at line 49 of file collection.h.

Referenced by cp_db_connection_pool_create(), cp_http_response_create(), cp_httpclient_set_parameter(), and cp_priority_list_create_by_option().

#define COLLECTION_MODE_PLAIN   0
 

use collection defaults

Definition at line 40 of file collection.h.


Typedef Documentation

typedef int(* cp_callback_fn)(void *entry, void *client_prm)
 

callback function for iterator callback etc

Definition at line 108 of file collection.h.

typedef int(* cp_compare_fn)(void *, void *)
 

comparator functions implement strcmp semantics - 0 for identical keys, non-zero otherwise.

Definition at line 103 of file collection.h.

typedef void*(* cp_copy_fn)(void *)
 

copy function.

In cases where the collection holds copies rather than references to the original objects. To do this you need to provide a copy function for the items.

Definition at line 92 of file collection.h.

Referenced by cp_http_response_create(), and cp_httpclient_set_parameter().

typedef void(* cp_destructor_fn)(void *)
 

destructor function.

Definition at line 97 of file collection.h.

Referenced by cp_db_connection_execute_statement_args(), cp_hashtable_remove_all(), cp_http_shutdown(), cp_httpclient_ctl_destroy(), cp_httpclient_init(), cp_httpsocket_delete(), cp_httpsocket_register_service(), cp_result_set_release_row(), cp_socket_add_shutdown_callback(), cp_socket_delete(), cp_socket_shutdown(), and cp_thread_pool_create().

typedef void*(* cp_key_fn)(void *record)
 

extract an alternate key from a record for indexing

Definition at line 127 of file collection.h.

typedef CPROPS_DLL struct _cp_wrap cp_wrap
 

lock for collection types - current implementation uses pthread_rwlock_t

_WINDOWS implementation for cp_cond is based on "Strategies for Implementing POSIX Condition Variables on _WINDOWS" by Douglas C. Schmidt and Irfan Pyarali see http://www.cs.wustl.edu/~schmidt/_WINDOWS-cv-1.html

Referenced by cp_http_add_shutdown_callback(), cp_socket_add_shutdown_callback(), and cp_tcp_add_shutdown_callback().


Generated on Sat Dec 1 10:25:30 2007 for cprops by  doxygen 1.3.9.1