Justtechjobs.com Find a programming school near you






Online Campus Both


php4-beta | 200004

Re: [PHP4BETA] Zend hash functions enchantments [PATCH] From: Andi Gutmans (andi <email protected>)
Date: 04/05/00

I don't think your patch is correct unless I'm missing something.
Two different strings can have the same length and the same hash value. It
doesn't seem as if your implementation works in this case.

Andi

On Wed, 5 Apr 2000, [ISO-8859-1] Jerry Lundström wrote:

> This is not a bug fix, just some enchantments.
> The enchantments will make it possible to add string based hash entrys
> and getting the index key for that entry. This will reduce a string key
> to two ints, the index key and the string key length.
>
> If you are unclear of its usage let me tell you why I needed it.
>
> I have a global object that I create other objects from and the
> global object is placed in the plist using a string based key
> like the mysql module is doing.
>
> These object needs to access the global object from time to time
> and haveing a refrence to the global object will not be good. If
> the global object is removed and the other objects jump into the
> refrence the server dies.
>
> By just adding two ints into the objects they can find the global
> object fast and clean without haveing to deal with strings and such.
>
>
>
> new functions are:
>
> ZEND_API int zend_hash_add_or_update_ret_key(
> ulong* ret_key,
> HashTable *ht,
> char *arKey,
> uint nKeyLength,
> void *pData,
> uint nDataSize,
> void **pDest,
> int flag);
>
> This function replaces zend_hash_add_or_update() and enables the user
> to get the index key back from adding a hashed value with a string
> key. This is to enable the user for finding the hash entry when useing
> the index key or the string key.
>
> Passing NULL to the ret_key will enable the normal functions that
> zend_hash_add_or_update() was so the zend_hash_add() and zend_hash_update()
> macros has been link to zend_hash_add_or_update_ret_key() with a NULL as
> ret_key.
>
>
> new macros for zend_hash_add_or_update_ret_key():
>
> zend_hash_update_ret_key(ret_key,ht,arKey,nKeyLength,pData,nDataSize,pDest)
> zend_hash_add_ret_key(ret_key,ht,arKey,nKeyLength,pData,nDataSize,pDest)
>
>
> new search function:
>
> ZEND_API int zend_hash_find_ret_key(
> ulong *ret_key,
> HashTable *ht,
> char *arKey,
> uint nKeyLength,
> void **pData);
>
> This function replaces zend_hash_find() in the same matter as
> zend_hash_add_or_update_ret_key() did for zend_hash_add_or_update().
>
> This will allow the user to search for a string based hash entry and get the
> index key back.
>
>
> ZEND_API int zend_hash_find_with_keylength(
> HashTable *ht,
> ulong h,
> uint nKeyLength,
> void **pData);
>
> This function is needed for searching string based hash entry with the index key.
> I do not know in depth how the hash algo work for zend but it is somewhat clear
> that we need to know the string length and the index key for searching.
>
> --
> Jerry Lundström:<jerry.lundstrom <email protected>>
> mobile+46.739.876053:phone+46.31.7107244:fax+46.31.7107201
> citat.solutions:Kronhusgatan.9:SE-411.05.Göteborg:Sweden
> www.citat.se/solutions
>

-- 
PHP 4.0 Beta Mailing List <http://www.php.net/version4/>
To unsubscribe, e-mail: php4beta-unsubscribe <email protected>
For additional commands, e-mail: php4beta-help <email protected>
To contact the list administrators, e-mail: php4beta-admin <email protected>