Drill down into the Java----collection----BitSet

Source: Internet
Author: User

Bitset class
The size can be dynamically changed, with a value of true or false for the bit set. Used to represent a set of Boolean flags.

There are three kinds of shift operators in Java

<<: Left shift operator, num << 1, equals num multiplied by 2

>>: Right shift operator, NUM >> 1, equivalent num divided by 2

>>>: Unsigned Right shift, ignore sign bit, empty 0

Why is 1l<<32 in Java equal to 4294967296, while 1<<32 equals 1.
You need to understand the binary storage form of integers and the basic operations of shift operations for integer shifts of type int a<<B, the system first with B to 32 to find the remainder, the result is the true shift of the number of digits for long type integer shift, ibid, but 64 for the remainder of 1L<< +, the actual number of bits moved 32% -= +for 1<< +, the actual number of bits moved 32% +=01L:
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00011L<< +:0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000=2^ +=4294967296 1:
0000 0000 0000 0000 0000 0000 0000 00011<< +:0000 0000 0000 0000 0000 0000 0000 0001=1

Words[wordindex] |= (1L << bitindex);
Equivalent to the Bitindex to 64 for the remainder operation (the left will be round), and then let 1 move to the rest of the array position, and then set this value to True

Drill down into the Java----collection----BitSet

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.