Use BigMap instance in PHP, and use BigMap instance _ PHP Tutorial in PHP

Source: Internet
Author: User
Use BigMap instances in PHP and BigMap instances in PHP. PHP uses BigMap instances. PHP uses BigMap instances. The so-called Bit-map in php uses a bit to mark the Value corresponding to an element, and the Key is the element. Because BigMap instances are used in PHP, BigMap instances are used in PHP.
<? Php // The so-called Bit-map uses a bit to mark the Value corresponding to an element, and the Key is the element. Because Bit is used to store data, the storage space can be greatly reduced. /* If N = 1; the applied memory space is int a [2]; suppose N = 10000000, then we need to apply for the memory size of int a [1 + N/32], where: a [0] occupies 32 of the memory and can correspond to the decimal number 0-31, and so on: 1. evaluate the subscript of 0-n in array a: n/32 2. evaluate the number in 0-N corresponding to 0-31: N % 32 = M3. use shift 0-31 to make the corresponding 32bit 1: 1 <
 
  
> SHIFT here is equivalent to intval ($ I/32); // $ I & $ this-> mask here is equivalent to $ I % $ this-> mask, remainder @ $ this-> bitArray [$ I >>$ this-> shift] & = ~ (1 <($ I & $ this-> mask);}/** $ I corresponds to 1 */function setbit ($ I) {@ $ this-> bitArray [$ I >>$ this-> shift] | = (1 <($ I & $ this-> mask ));} // test whether the test bit is 1 function testbit ($ I) {return $ this-> bitArray [$ I >>$ this-> shift] & (1 <($ I & $ this-> mask ));}} $ oBig = new bigMap (); $ oBig-> setbit (30); var_dump ($ oBig-> testbit (2); var_dump ($ oBig-> bitArray ); echo decbin ($ oBig-> bitArray [0]),"
  
";

Php // The so-called Bit-map is to use a bit to mark the Value corresponding to an element, and the Key is the element. Because Bit is used as the unit...

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.