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

KHash.h File Reference

Hash Table structure. More...

#include "ktypes.h"
#include "KList.h"
#include "KCList.h"

Defines

#define KHash_new(cmp_func, hash_func)   _KHash_new (cmp_func, hash_func, __K_FILE__, __K_LINE__)
 Creates an empty hash table.
#define KHash_print_si(hash)   KHash_print (hash, KHash_kstring_print, KHash_kint_print)
 Function that displays the hash table on the standard output (the keys are strings and the values are integral numbers).
#define KHash_print_ss(hash)   KHash_print (hash, KHash_kstring_print, KHash_kstring_print)
 Function that displays the hash table on the standard output (the keys are strings and the values are strings too).
#define KHash_print_s(hash, printvalue_func)   KHash_print (hash, KHash_kstring_print, printvalue_func)
 Function that displays the hash table on the standard output (the keys are strings).

Typedefs

typedef _KHash KHash
 Hash table.
typedef KUIntKHash_hash_func )(KCPtr)
 Hash table functions.
typedef void( KHash_printkey_func )(KCPtr)
 Print functions of a key.
typedef void( KHash_printvalue_func )(KCPtr)
 Print functions of a value.
typedef KBoolKHash_foreach_func )(KCPtr key, KPtr values, KPtr datas)
 Print function of values from a hash table.

Functions

KTL_API KHash_KHash_new (KFunc_cmp *cmp_func, KHash_hash_func *hash_func, KString sFile, KInt32 iLine)
 Creates an empty hash table.
KTL_API void KHash_delete (KHash **khash)
 Deletes a hash table.
KTL_API KBool KHash_insert (KHash *khash, KCPtr key, KPtr value)
 Inserts an element in a hash table.
KTL_API KBool KHash_is_key (KHash *khash, KPtr key)
 Searches of a key from a hash table.
KTL_API KPtr KHash_get_value (KHash *khash, KCPtr key)
 Gets the value corresponding to a key in a hash table.
KTL_API KListKHash_get_all_values (KHash *hash)
 Gets all the values from a hash table.
KTL_API KBool KHash_remove_key (KHash *khash, KCPtr key)
 Removes a key and its value from a hash table.
KTL_API KBool KHash_remove_all_values (KHash *khash, KPtr value)
 Removes all the keys of a same value from a hash table.
KTL_API KBool KHash_remove_all_keys (KHash *hash)
 Removes all keys from a hash table.
KTL_API KUInt32 KHash_size (KHash *khash)
 Returns the number of elements of a hash table.
KTL_API KUInt KHash_kstring_hash (KCPtr v)
 Hash function for strings.
KTL_API KUInt KHash_kint_hash (KCPtr v)
 Hash function for integral numbers.
KTL_API KInt KHash_kstring_cmp (KCPtr p1, KCPtr p2)
 Comparison function for strings.
KTL_API KUInt KHash_kint64_hash (KCPtr v)
 Hash function for 64 bits integral numbers.
KTL_API KInt KHash_kint64_cmp (KCPtr p1, KCPtr p2)
 Comparison function for 64 bits integral numbers.
KTL_API KUInt KHash_kuint32_hash (KCPtr v)
 Hash function for 32 bits integral numbers.
KTL_API KInt KHash_kuint32_cmp (KCPtr p1, KCPtr p2)
 Comparison function for 32 bits integral numbers.
KTL_API KInt KHash_kint_cmp (KCPtr p1, KCPtr p2)
 Comparison function for integral numbers.
KTL_API void KHash_kint_print (KCPtr p)
 Function that displays an integral number on the standard output.
KTL_API void KHash_kstring_print (KCPtr p)
 Function that displays a string on the standard output.
KTL_API void KHash_print (KHash *hash, KHash_printkey_func *printkey_func, KHash_printvalue_func *printvalue_func)
 Function that displays the hash table on the standard output.
KTL_API KBool KHash_checkup (KHash *hash, KPtr *keys, KPtr *values, const KInt64 n)
 Verifies the correctness of a hash table.
KTL_API KBool KHash_foreach (KHash *hash, KHash_foreach_func *foreach_func, KPtr datas)
 Applies the same function to all couples key-value of a hash table.
KTL_API KCListKHash_getAllKeys (KHash *hash)
 Returns all the keys from a hash table.
KTL_API KCPtr KHash_iter_begin (KHash *hash)
 Returns the first key from a hash table.
KTL_API KCPtr KHash_iter_next (KHash *hash)
 Returns the next key from a hash table.


Detailed Description

Hash Table structure.

Version:
KToolLib-1.0
Author:
Fabien Gallot
Date:
28/10/2008
Note:
Copyright © 2008-2010 iKlax Media SAS (www.iklaxmedia.com). All rights reserved.

Define Documentation

#define KHash_new cmp_func,
hash_func   )     _KHash_new (cmp_func, hash_func, __K_FILE__, __K_LINE__)
 

Creates an empty hash table.

Parameters:
cmp_func the comparison function
hash_func ??
Returns:
the pointer to the created hash table if successful otherwise knull

#define KHash_print_s hash,
printvalue_func   )     KHash_print (hash, KHash_kstring_print, printvalue_func)
 

Function that displays the hash table on the standard output (the keys are strings).

Parameters:
hash the pointer to the hash table to be displayed
printvalue_func the pointer to the function that prints the values on the standard output

#define KHash_print_si hash   )     KHash_print (hash, KHash_kstring_print, KHash_kint_print)
 

Function that displays the hash table on the standard output (the keys are strings and the values are integral numbers).

Parameters:
hash the pointer to the hash table to be displayed

#define KHash_print_ss hash   )     KHash_print (hash, KHash_kstring_print, KHash_kstring_print)
 

Function that displays the hash table on the standard output (the keys are strings and the values are strings too).

Parameters:
hash the pointer to the hash table to be displayed


Function Documentation

KTL_API KHash* _KHash_new KFunc_cmp cmp_func,
KHash_hash_func hash_func,
KString  sFile,
KInt32  iLine
 

Creates an empty hash table.

Parameters:
cmp_func the comparison function
hash_func ??
sFile the file name where this function is called
iLine the line number where this function is called
Returns:
the pointer to the created hash table if successful otherwise knull

KTL_API KBool KHash_checkup KHash hash,
KPtr keys,
KPtr values,
const KInt64  n
 

Verifies the correctness of a hash table.

Parameters:
hash the pointer to the hash table to be verified
keys the pointer to the keys of the hash table
values the pointer to the values of the hash table
n the size of the hash table
Returns:
ktrue if the hash table is correct otherwise kfalse

KTL_API void KHash_delete KHash **  khash  ) 
 

Deletes a hash table.

Parameters:
khash the pointers to the hash table to be deleted

KTL_API KBool KHash_foreach KHash hash,
KHash_foreach_func foreach_func,
KPtr  datas
 

Applies the same function to all couples key-value of a hash table.

Parameters:
hash the pointer to the hash table which the function should be applied
foreach_func the pointer to the function to be applied
datas ??
Returns:
ktrue if successful otherwise kfalse

KTL_API KList* KHash_get_all_values KHash hash  ) 
 

Gets all the values from a hash table.

Parameters:
hash the pointer to the hash table
Returns:
the pointer to the list where values are stored if successful otherwise knull

KTL_API KPtr KHash_get_value KHash khash,
KCPtr  key
 

Gets the value corresponding to a key in a hash table.

Parameters:
khash the pointer to the hash table
key the pointer to the key which corresponding value should be obtained
Returns:
the pointer to the value to be obtained if successful otherwise knull

KTL_API KCList* KHash_getAllKeys KHash hash  ) 
 

Returns all the keys from a hash table.

Parameters:
hash the pointer to the hash table
Returns:
the pointer to a list which contains all the keys of the hash table if successful otherwise knull

KTL_API KBool KHash_insert KHash khash,
KCPtr  key,
KPtr  value
 

Inserts an element in a hash table.

Parameters:
khash the pointer to the hash table where element should be inserted
key the key of the element to be inserted
value the value of the element to be inserted
Returns:
ktrue if successful otherwise kfalse

KTL_API KBool KHash_is_key KHash khash,
KPtr  key
 

Searches of a key from a hash table.

Parameters:
khash the pointer to the hash table
key the pointer to the key to be searched
Returns:
ktrue if successful otherwise kfalse

KTL_API KCPtr KHash_iter_begin KHash hash  ) 
 

Returns the first key from a hash table.

Parameters:
hash the pointer to the hash table
Returns:
the pointer to the first key if successful otherwise knull

KTL_API KCPtr KHash_iter_next KHash hash  ) 
 

Returns the next key from a hash table.

Parameters:
hash the pointer to the hash table
Returns:
the pointer to the next key if it exists otherwise knull

KTL_API KInt KHash_kint64_cmp KCPtr  p1,
KCPtr  p2
 

Comparison function for 64 bits integral numbers.

Parameters:
p1 the pointer to the first integral number
p2 the pointer to the second integral number
Returns:
an integral number indicating the relationship between the 64 bits integral numbers. A zero value indicates that both 64 bits integral numbers are equal. A value greater than zero indicates that the first 64 bits integral number is greater than the second one. A value less than zero indicates the opposite

KTL_API KUInt KHash_kint64_hash KCPtr  v  ) 
 

Hash function for 64 bits integral numbers.

Parameters:
v ??
Returns:
??

KTL_API KInt KHash_kint_cmp KCPtr  p1,
KCPtr  p2
 

Comparison function for integral numbers.

Parameters:
p1 the pointer to the first integral number
p2 the pointer to the second integral number
Returns:
an integral number indicating the relationship between the integral numbers. A zero value indicates that both integral numbers are equal. A value greater than zero indicates that the first integral number is greater than the second one. A value less than zero indicates the opposite

KTL_API KUInt KHash_kint_hash KCPtr  v  ) 
 

Hash function for integral numbers.

Parameters:
v ??
Returns:
??

KTL_API void KHash_kint_print KCPtr  p  ) 
 

Function that displays an integral number on the standard output.

Parameters:
p the pointer to the integral number to be displayed

KTL_API KInt KHash_kstring_cmp KCPtr  p1,
KCPtr  p2
 

Comparison function for strings.

Parameters:
p1 the pointer to the first string
p2 the pointer to the second string
Returns:
an integral number indicating the relationship between the strings. A zero value indicates that both strings are equal. A value greater than zero indicates that the first character that does not match has a greater value in the first string than in the second one. A value less than zero indicates the opposite

KTL_API KUInt KHash_kstring_hash KCPtr  v  ) 
 

Hash function for strings.

Parameters:
v ??
Returns:
??

KTL_API void KHash_kstring_print KCPtr  p  ) 
 

Function that displays a string on the standard output.

Parameters:
p the pointer to the string to be displayed

KTL_API KInt KHash_kuint32_cmp KCPtr  p1,
KCPtr  p2
 

Comparison function for 32 bits integral numbers.

Parameters:
p1 the pointer to the first integral number
p2 the pointer to the second integral number
Returns:
an integral number indicating the relationship between the 32 bits integral numbers. A zero value indicates that both 32 bits integral numbers are equal. A value greater than zero indicates that the first 32 bits integral number is greater than the second one. A value less than zero indicates the opposite

KTL_API KUInt KHash_kuint32_hash KCPtr  v  ) 
 

Hash function for 32 bits integral numbers.

Parameters:
v ??
Returns:
??

KTL_API void KHash_print KHash hash,
KHash_printkey_func printkey_func,
KHash_printvalue_func printvalue_func
 

Function that displays the hash table on the standard output.

Parameters:
hash the pointer to the hash table to be displayed
printkey_func the pointer to the function that prints the keys on the standard output
printvalue_func the pointer to the function that prints the values on the standard output

KTL_API KBool KHash_remove_all_keys KHash hash  ) 
 

Removes all keys from a hash table.

Parameters:
hash the pointer to the hash table
Returns:
ktrue if successful otherwise kfalse

KTL_API KBool KHash_remove_all_values KHash khash,
KPtr  value
 

Removes all the keys of a same value from a hash table.

Parameters:
khash the pointer to the hash table
value the pointer to the value to be removed
Returns:
ktrue

KTL_API KBool KHash_remove_key KHash khash,
KCPtr  key
 

Removes a key and its value from a hash table.

Parameters:
khash the pointer to the hash table
key the pointer to the key to be removed
Returns:
ktrue if the key is found otherwise kfalse

KTL_API KUInt32 KHash_size KHash khash  ) 
 

Returns the number of elements of a hash table.

Parameters:
khash the pointer to the hash table
Returns:
the number of elements of the hash table


Generated on Tue Mar 9 10:49:29 2010 for iKlax Tools Library (KToolLib) by doxygen 1.3.8