Zend hash functions enchantments [PATCH]
| From: | Jerry Lundström | Date: | Wed, 05 Apr 2000 13:16:41 +0000 |
| Subject: | Zend hash functions enchantments [PATCH] | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-13164@lists.php.net to get a copy of this message | ||
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@citat.se>
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
Attachment: [application/octet-stream] zend_hash_ret_key.diff
Attachment: [application/octet-stream] zend_hash_ret_key.diff