|
|
@ -108,47 +108,87 @@ struct ast_hashtab_iter
|
|
|
|
|
|
|
|
|
|
|
|
/* some standard, default routines for general use */
|
|
|
|
/* some standard, default routines for general use */
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief For sizing the hash table, tells if num is prime or not */
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief Determines if the specified number is prime.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \param num the number to test
|
|
|
|
|
|
|
|
* \retval 0 if the number is not prime
|
|
|
|
|
|
|
|
* \retval 1 if the number is prime
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_is_prime(int num);
|
|
|
|
int ast_is_prime(int num);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief assumes a and b are char *
|
|
|
|
* \brief Compares two strings for equality.
|
|
|
|
* \return 0 if they match
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
* \param a a character string
|
|
|
|
|
|
|
|
* \param b a character string
|
|
|
|
|
|
|
|
* \retval 0 if the strings match
|
|
|
|
|
|
|
|
* \retval <0 if string a is less than string b
|
|
|
|
|
|
|
|
* \retval >0 if string a is greather than string b
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_hashtab_compare_strings(const void *a, const void *b);
|
|
|
|
int ast_hashtab_compare_strings(const void *a, const void *b);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief assumes a & b are strings
|
|
|
|
* \brief Compares two strings for equality, ignoring case.
|
|
|
|
* \return 0 if they match (strcasecmp)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
* \param a a character string
|
|
|
|
|
|
|
|
* \param b a character string
|
|
|
|
|
|
|
|
* \retval 0 if the strings match
|
|
|
|
|
|
|
|
* \retval <0 if string a is less than string b
|
|
|
|
|
|
|
|
* \retval >0 if string a is greather than string b
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_hashtab_compare_strings_nocase(const void *a, const void *b);
|
|
|
|
int ast_hashtab_compare_strings_nocase(const void *a, const void *b);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief assumes a & b are int *
|
|
|
|
* \brief Compares two integers for equality.
|
|
|
|
* \retval 0 if match
|
|
|
|
*
|
|
|
|
* \retval 1 a > b
|
|
|
|
* \param a an integer pointer (int *)
|
|
|
|
* \retval -1 a < b
|
|
|
|
* \param b an integer pointer (int *)
|
|
|
|
*/
|
|
|
|
* \retval 0 if the integers pointed to are equal
|
|
|
|
|
|
|
|
* \retval 1 if a is greater than b
|
|
|
|
|
|
|
|
* \retval -1 if a is less than b
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_hashtab_compare_ints(const void *a, const void *b);
|
|
|
|
int ast_hashtab_compare_ints(const void *a, const void *b);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief assumes a & b are short *
|
|
|
|
* \brief Compares two shorts for equality.
|
|
|
|
* \retval 0 if match
|
|
|
|
*
|
|
|
|
* \retval 1 a > b
|
|
|
|
* \param a a short pointer (short *)
|
|
|
|
* \retval -1 a < b
|
|
|
|
* \param b a short pointer (short *)
|
|
|
|
*/
|
|
|
|
* \retval 0 if the shorts pointed to are equal
|
|
|
|
|
|
|
|
* \retval 1 if a is greater than b
|
|
|
|
|
|
|
|
* \retval -1 if a is less than b
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_hashtab_compare_shorts(const void *a, const void *b);
|
|
|
|
int ast_hashtab_compare_shorts(const void *a, const void *b);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief determine if resize should occur
|
|
|
|
* \brief Determines if a table resize should occur using the Java algorithm
|
|
|
|
* \returns 1 if the table is 75% full or more
|
|
|
|
* (if the table load factor is 75% or higher).
|
|
|
|
*/
|
|
|
|
*
|
|
|
|
|
|
|
|
* \param tab the hash table to operate on
|
|
|
|
|
|
|
|
* \retval 0 if the table load factor is less than or equal to 75%
|
|
|
|
|
|
|
|
* \retval 1 if the table load factor is greater than 75%
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_hashtab_resize_java(struct ast_hashtab *tab);
|
|
|
|
int ast_hashtab_resize_java(struct ast_hashtab *tab);
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief no resizing; always return 0 */
|
|
|
|
/*! \brief Causes a resize whenever the number of elements stored in the table
|
|
|
|
|
|
|
|
* exceeds the number of buckets in the table.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \param tab the hash table to operate on
|
|
|
|
|
|
|
|
* \retval 0 if the number of elements in the table is less than or equal to
|
|
|
|
|
|
|
|
* the number of buckets
|
|
|
|
|
|
|
|
* \retval 1 if the number of elements in the table exceeds the number of
|
|
|
|
|
|
|
|
* buckets
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_hashtab_resize_tight(struct ast_hashtab *tab);
|
|
|
|
int ast_hashtab_resize_tight(struct ast_hashtab *tab);
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief no resizing; always return 0 */
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief Effectively disables resizing by always returning 0, regardless of
|
|
|
|
|
|
|
|
* of load factor.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \param tab the hash table to operate on
|
|
|
|
|
|
|
|
* \return 0 is always returned
|
|
|
|
|
|
|
|
*/
|
|
|
|
int ast_hashtab_resize_none(struct ast_hashtab *tab);
|
|
|
|
int ast_hashtab_resize_none(struct ast_hashtab *tab);
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief Create a prime number roughly 2x the current table size */
|
|
|
|
/*! \brief Create a prime number roughly 2x the current table size */
|
|
|
@ -162,16 +202,35 @@ int ast_hashtab_newsize_none(struct ast_hashtab *tab);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* \brief Hashes a string to a number
|
|
|
|
* \brief Hashes a string to a number
|
|
|
|
* \param obj
|
|
|
|
*
|
|
|
|
* \note A modulus is applied so it in the range 0 to mod-1
|
|
|
|
* \param obj the string to hash
|
|
|
|
*/
|
|
|
|
* \return Integer hash of the specified string
|
|
|
|
|
|
|
|
* \sa ast_hashtable_hash_string_nocase
|
|
|
|
|
|
|
|
* \sa ast_hashtab_hash_string_sax
|
|
|
|
|
|
|
|
* \note A modulus will be applied to the return value of this function
|
|
|
|
|
|
|
|
*/
|
|
|
|
unsigned int ast_hashtab_hash_string(const void *obj);
|
|
|
|
unsigned int ast_hashtab_hash_string(const void *obj);
|
|
|
|
|
|
|
|
|
|
|
|
/*! \brief Upperases each char before using them for a hash */
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* \brief Hashes a string to a number ignoring case
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \param obj the string to hash
|
|
|
|
|
|
|
|
* \return Integer hash of the specified string
|
|
|
|
|
|
|
|
* \sa ast_hashtable_hash_string
|
|
|
|
|
|
|
|
* \sa ast_hashtab_hash_string_sax
|
|
|
|
|
|
|
|
* \note A modulus will be applied to the return value of this function
|
|
|
|
|
|
|
|
*/
|
|
|
|
unsigned int ast_hashtab_hash_string_nocase(const void *obj);
|
|
|
|
unsigned int ast_hashtab_hash_string_nocase(const void *obj);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
unsigned int ast_hashtab_hash_string_sax(const void *obj); /* from Josh */
|
|
|
|
* \brief Hashes a string to a number using a modified Shift-And-XOR algorithm
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* \param obj the string to hash
|
|
|
|
|
|
|
|
* \return Integer has of the specified string
|
|
|
|
|
|
|
|
* \sa ast_hastable_hash_string
|
|
|
|
|
|
|
|
* \sa ast_hastable_hash_string_nocase
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
unsigned int ast_hashtab_hash_string_sax(const void *obj);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int ast_hashtab_hash_int(const int num); /* right now, both these funcs are just result = num%modulus; */
|
|
|
|
unsigned int ast_hashtab_hash_int(const int num); /* right now, both these funcs are just result = num%modulus; */
|
|
|
|