Use boost for crc64 computing

Source: Internet
Author: User

Because of the platform access, the platform provides a string key as the user ID, and distributed is required, so the user ID cannot be incremental with the previous database, therefore, crc64 is used to generate uint64_t as the user ID, which is also relatively simple. Casino:

STD: Map <size_t, size_t> xlongmap; char sztemp [128] = {0}; Boost: crc_optimal <64, 0x04c11db7, 0, 0, false, false> CRC; for (uint32_t I = 0; I <1000000000; ++ I) {memset (sztemp, 0, sizeof (sztemp); sprintf_s (sztemp, "% d % S % s", I, "1a2b3c", "4d5e6f", "7g8h9i"); CRC. process_bytes (sztemp, strlen (sztemp); size_t NPOs = CRC. checksum (); CRC. reset (); If (! Xlongmap. insert (STD: Map <size_t, size_t>: value_type (NPOs, 0 )). second) {STD: cout <"repeated, current quantity:" <I <", string:" <sztemp <", hash pos: "<NPOs <STD: Endl; System (" pause "); break ;}}

Must contain boost/CRC. HPP

In the test, there were no duplicates in 0.13 billion, which was quite powerful.

Unfortunately, this algorithm is not used later, because the key contains URL escape, resulting in % such characters, and other methods are used later.

Use boost for crc64 computing

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.