group Hashes

Description

How could any program survive without hashing? The hash functions below provide a good hashing system implementation which is used throughout the ferite engine. They can be used to store anything and form the basis for namespaces.

group attributes
function ferite_create_hash() - Create a hash table
function ferite_delete_hash() - Delete a hash table
function ferite_process_hash() - Process a hash table by calling a function on each element
function ferite_hash_add() - Add data to the hash
function ferite_hash_get() - Get the data at a specified key
function ferite_create_iterator() - Create an iterator to iterate over a hash
function ferite_hash_walk() - Walk the hash
function ferite_hash_update() - Update a value at the specified hash key
function ferite_hash_delete() - Delete a key from the hash
function ferite_hash_dup() - Duplicate a hash
function ferite_hash_grow() - Grow the hash table to be faster
function ferite_hash_print() - Print out the hash table if debug mode is turned on

Functions

function ferite_create_hash Click to go up to the list
Create a hash table
Declaration:
    FeriteHash *ferite_create_hash( FeriteScript *script, int size )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: int size - The initial size of the hash
Returns:
    A new hash table

function ferite_delete_hash Click to go up to the list
Delete a hash table
Declaration:
    void ferite_delete_hash( FeriteScript *script, FeriteHash *hash, void (*cb)(FeriteScript*,void *data) )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteHash *hash - The hash table to delete
    Parameter #3: void cb - The function to call to delete the hash's contents

function ferite_process_hash Click to go up to the list
Process a hash table by calling a function on each element
Declaration:
    void ferite_process_hash( FeriteScript *script, FeriteHash *hash, void (*cb)(FeriteScript*,void *data) )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteHash *hash - The hash table to process
    Parameter #3: void cb - The function to call to process the hash's contents

function ferite_hash_add Click to go up to the list
Add data to the hash
Declaration:
    void ferite_hash_add( FeriteScript *script, FeriteHash *hash, char *key, void *data )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteHash *hash - The hash to insert the data into
    Parameter #3: char *key - The key on which to hash the data
    Parameter #4: void *data - A pointer to some data to keep

function ferite_hash_get Click to go up to the list
Get the data at a specified key
Declaration:
    void *ferite_hash_get( FeriteScript *script, FeriteHash *hash, char *key )
Parameters:
    Parameter #1: FeriteScript *script - The script to pass around
    Parameter #2: FeriteHash *hash - The hash to get the data from
    Parameter #3: char *key - The key to obtain the data for
Returns:
    The pointer to the data or NULL otherwise

function ferite_create_iterator Click to go up to the list
Create an iterator to iterate over a hash
Declaration:
    FeriteIterator *ferite_create_iterator( FeriteScript *script )
Parameters:
    Parameter #1: FeriteScript *script - The script
Returns:
    A pointer to an iterator

function ferite_hash_walk Click to go up to the list
Walk the hash
Declaration:
    FeriteHashBucket *ferite_hash_walk(FeriteScript *script, FeriteHash *hash, FeriteIterator *iter)
Description:
Each time this function is called it will return the next data value
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteHash *hash - The hash to walk over
    Parameter #3: FeriteIterator *iter - The iterator to use
Returns:
    The next hash bucket, NULL if there are no more

function ferite_hash_update Click to go up to the list
Update a value at the specified hash key
Declaration:
    void ferite_hash_update( FeriteScript *script, FeriteHash *hash, char *key, char *data )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteHash *hash - The has to update
    Parameter #3: char *key - The key to the bucket to update
    Parameter #4: char *data - Pointer to the data

function ferite_hash_delete Click to go up to the list
Delete a key from the hash
Declaration:
    void ferite_hash_delete( FeriteScript *script, FeriteHash *hash, char *key )
Parameters:
    Parameter #1: FeriteScript *script - The script to delete
    Parameter #2: FeriteHash *hash - The hash to delete from
    Parameter #3: char *key - The key to delete

function ferite_hash_dup Click to go up to the list
Duplicate a hash
Declaration:
    FeriteHash *ferite_hash_dup( FeriteScript *script, FeriteHash *hash, void *(*ddup)( FeriteScript*,void *data,void *data2 ), void *data2 )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteHash *hash - The hash table to duplicate
    Parameter #3: void *ddup - The function that gets called with to duplicate a buckets data
Returns:
    A new hash that is an exact copy of the original

function ferite_hash_grow Click to go up to the list
Grow the hash table to be faster
Declaration:
    FeriteHash *ferite_hash_grow( FeriteScript *script, FeriteHash *hash )
Parameters:
    Parameter #1: FeriteScript *script - The script
    Parameter #2: FeriteHash *hash - The hash to modify
Returns:
    The pointer to the new hash (this may be the same as the passed in hash)

function ferite_hash_print Click to go up to the list
Print out the hash table if debug mode is turned on
Declaration:
    void ferite_hash_print( FeriteScript *script, FeriteHash *hash )
Description:
This simply prints out what keys are in the hash for debug purposes
Parameters:
    Parameter #1: FeriteScript *script - The script to delete
    Parameter #2: FeriteHash *hash - The has to print out

Automatically generated at 8:45pm, Wednesday 08 January 2003 by feritedoc.