trie.h File Reference

#include "common.h"
#include "config.h"
#include <string.h>
#include <errno.h>
#include "hashtable.h"
#include "vector.h"
#include "mtab.h"
#include "mempool.h"

Go to the source code of this file.

Data Structures

struct  _cp_trie_node
struct  _cp_trie

Defines

#define NODE_MATCH(n, i)   ((n)->others ? mtab_get((n)->others, *i) : NULL)
#define BRANCH_COUNT(node)   mtab_count((node)->others)
#define cp_trie_rdlock(grp)   (cp_trie_lock(grp, COLLECTION_LOCK_READ))
#define cp_trie_wrlock(grp)   (cp_trie_lock(grp, COLLECTION_LOCK_WRITE))

Typedefs

typedef int(*) cp_trie_match_fn (void *leaf)
typedef CPROPS_DLL struct
_cp_trie_node 
cp_trie_node
typedef CPROPS_DLL struct
_cp_trie 
cp_trie

Functions

CPROPS_DLL cp_trie_node * cp_trie_node_new (void *leaf, cp_mempool *pool)
CPROPS_DLL void * cp_trie_node_delete (struct _cp_trie *grp, cp_trie_node *node)
CPROPS_DLL void cp_trie_delete_mapping (struct _cp_trie *grp, mtab_node *map_node)
CPROPS_DLL void cp_trie_node_unmap (struct _cp_trie *grp, cp_trie_node **node)
CPROPS_DLL cp_trie * cp_trie_create_trie (int mode, cp_copy_fn copy_leaf, cp_destructor_fn delete_leaf)
CPROPS_DLL cp_trie * cp_trie_create (int mode)
CPROPS_DLL int cp_trie_destroy (cp_trie *grp)
CPROPS_DLL int cp_trie_add (cp_trie *grp, char *key, void *leaf)
CPROPS_DLL int cp_trie_remove (cp_trie *grp, char *key, void **leaf)
CPROPS_DLL int cp_trie_prefix_match (cp_trie *grp, char *key, void **leaf)
CPROPS_DLL void * cp_trie_exact_match (cp_trie *grp, char *key)
CPROPS_DLL cp_vector * cp_trie_fetch_matches (cp_trie *grp, char *key)
CPROPS_DLL cp_vector * cp_trie_submatch (cp_trie *grp, char *key)
CPROPS_DLL int cp_trie_count (cp_trie *grp)
CPROPS_DLL void cp_trie_set_root (cp_trie *grp, void *leaf)
CPROPS_DLL int cp_trie_lock (cp_trie *grp, int type)
CPROPS_DLL int cp_trie_unlock (cp_trie *grp)
CPROPS_DLL int cp_trie_get_mode (cp_trie *grp)
CPROPS_DLL int cp_trie_set_mode (cp_trie *grp, int mode)
CPROPS_DLL int cp_trie_unset_mode (cp_trie *grp, int mode)
CPROPS_DLL void cp_trie_dump (cp_trie *grp)
CPROPS_DLL int cp_trie_use_mempool (cp_trie *tree, cp_mempool *pool)
CPROPS_DLL int cp_trie_share_mempool (cp_trie *tree, cp_shared_mempool *pool)


Detailed Description

cp_trie is a character trie implementation. Tries allow for prefix matching with O(m) = O(1) time (m being the length of the key). Used to store key - value mappings, tries have certain advantages over hashtables in that worse case behavior is still O(1) and no hash function is needed. cp_trie is technically a compact trie in that collapses unused character paths.

Definition in file trie.h.


Generated on Mon Dec 5 23:00:22 2011 for cprops by  doxygen 1.4.7