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

hashtree.h File Reference


Detailed Description

Hash tree implementation, not yet memory and speed optimized yet.

Author:
Jeroen Asselman
Date:
2003

Go to the source code of this file.

Data Structures

struct  node_s
struct  hashtree_s

Typedefs

typedef node_s node_t
typedef hashtree_s hashtree

Functions

hashtreehashtree_new (gpointer(*hash_func)(gpointer, gpointer))
 Create a new hashtree.

void hashtree_append_leaf_node (hashtree *parent, gpointer hash)
 Append leaf node to hash tree.

void hashtree_finish (hashtree *parent)
 Finish the hashtree.

void hashtree_destroy (hashtree *tree)
 Destroy the hashtree.


Typedef Documentation

typedef struct hashtree_s hashtree
 

typedef struct node_s node_t
 


Function Documentation

void hashtree_append_leaf_node hashtree tree,
gpointer  hash
 

Append leaf node to hash tree.

Adds a new leaf node to the hashtree, if necesarry it will expand the hashtree to include the new leaf node.

Parameters:
tree is a pointer to the hashtree to perform this action on.
hash is a pointer to a hash which should be included with the leaf node. This hash must be a pointer allocated with g_malloc as this hashtree will free this pointer with g_free later when the hashtree is destroyed.

void hashtree_destroy hashtree tree  ) 
 

Destroy the hashtree.

Destroys the hash tree and all its included node. This will free all memory used by the hashtree, including all hashes assigned to a node which was added with hashtree_append_leaf_node which will be freed using g_free

Parameters:
tree is a pointer to the hashtree to perform this action on.

void hashtree_finish hashtree tree  ) 
 

Finish the hashtree.

Calculates all internal hashes in the hashtree. Call this function when you are ready with adding leaf nodes to the hashtree.

Parameters:
tree is a pointer to the hashtree to perform this action on.

hashtree* hashtree_new gpointer(*  hash_func)(gpointer, gpointer)  ) 
 

Create a new hashtree.

Initializes a new hashtree. Save the returned hashtree pointer which you need to pass to the other hashtree functions.

Parameters:
hash_func a hash function which should be used to calculate the internal hash. The signature of the hash_func must be: gpointer *hash_func(gpointer hash1, gpointer hash2) The returned hash must be allocated with g_malloc() as this hashtree implementation will free it later with g_free().
Returns:
a pointer to the new created hashtree.


Generated on Sun Feb 12 10:50:02 2006 for Gtk-Gnutella by doxygen 1.3.6