PHP Kernel Explorer: Hash table in PHP

Source: Internet
Author: User

PHP implementation of the array directly with the hash table to achieve, I just want to say that the author is too clever, this article introduces the hash algorithm in PHP, the future of their own design framework will be very helpful. At the same time, the weak type of PHP design ingenious, it can be reference to the design! PHP is the best Web language in the World ~ ~ Not Black ~ ~

It is widely used in practice, such as a symbol table that compilers typically maintain to hold tags, and a hash table is also explicitly supported in many high-level languages. A hash table usually provides operations such as find (search), insert, Delete, and so on, in the worst case, the same as the performance of the list O (n). But usually not so bad, a reasonably designed hashing algorithm can effectively avoid such situations, usually the hash table of these operating time complexity is O (1). This is why it is beloved.

Methods for resolving hash conflicts PHP uses the link method, that is, the different keys are mapped to the same bucket or slot, and the list is used to save the value, if all the keys are mapped to the same slot, that is the worst case of the operation of the list of Complexity O (n). There is also a way to resolve conflicts is open addressing, that is, if the index of a bucket has values, go to the next bucket to index, and then check.

Original: http://www.nowamagic.net/librarys/veda/detail/1344

PHP Kernel Explorer: Hash table in PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.