The phphash algorithm implements arrays. The most commonly used non-Array in PHP does not belong to. how is Array implemented? In PHP, the Array is implemented through a hashtable, and the link method is used to solve the hash conflict problem. in this way, the most used non-Array in PHP is the worst case, how is Array implemented? In PHP, the internal Array is implemented through a hashtable, and the hash conflict is solved using the link method. in this case, the complexity of searching Array elements is O (N ), preferably 1.
The most commonly used non-Array in PHP does not belong to. how is Array implemented? In PHP, the internal Array is implemented through a hashtable, and the hash conflict is solved using the link method. in this case, the complexity of searching Array elements is O (N ), preferably 1.
Static inline ulong zend_inline_hash_func (const char * arKey, uint nKeyLength)
{
Register ulong hash = 5381; // is there any xuanjicang in the initial value settings?
/* Variant with the hash unrolled eight times */
For (; nKeyLength> = 8; nKeyLength-= 8) {// why is this step = 8?
Hash = (hash <5) + hash) + * arKey ++;
Hash = (hash <5) + hash) + * arKey ++;
Hash = (hash <5) + hash) + * arKey ++;
Hash = (hash <5) + hash) + * arKey ++; // faster than * 33
Hash = (hash <5) + hash) + * arKey ++;
Hash = (hash <5) + hash) + * arKey ++;
Hash = (hash <5) + hash) + * arKey ++;
Hash = (hash <5) + hash) + * arKey ++;
}
Switch (nKeyLength ){
Case 7: hash = (hash <5) + hash) + * arKey ++;/* fallthrough... * // the remaining characters are hashed here
Case 6: hash = (hash <5) + hash) + * arKey ++;/* fallthrough ...*/
Case 5: hash = (hash <5) + hash) + * arKey ++;/* fallthrough ...*/
Case 4: hash = (hash <5) + hash) + * arKey ++;/* fallthrough ...*/
Case 3: hash = (hash <5) + hash) + * arKey ++;/* fallthrough ...*/
Case 2: hash = (hash <5) + hash) + * arKey ++;/* fallthrough ...*/
Case 1: hash = (hash <5) + hash) + * arKey ++; break;
Case 0: break;
EMPTY_SWITCH_DEFAULT_CASE ()
}
Return hash; // return the hash value.
}
Why? In PHP, Array is implemented through a hashtable, and the link method is used to solve the hash conflict problem. this is the worst case...