bitset_java

在Java的文档中说明了BitSet实现了Vector接口,是一个可按需增加的存储位的数据结构,位的值位布尔型,初始大小为64bit,初始值均为“false”。数据结构

经常使用方法:code

  • void set(int bitIndex)、void set(int bitIntex, boolean value) : 将bitIndex位置的值设为“true”或者给定的值对象

  • boolean get(int bitIndex) :获取bitIndex位置处的值索引

  • BitSet get(int fromIndex, int toIndex) :以BitSet存储返回fromIndex与toIndex区间之间的值接口

  • void clear()、void clear(int bitIndex)、void clear(int fromIndex, int toIndex) :置整个BitSet/相应位置/区间的值为“false”ci

  • int length() :BitSet的逻辑大小(实际使用大小),值为“true”最大的索引位加1文档

  • int size() :BitSet的实际大小,默认为64get

  • and(BitSet set)、andNot(BitSet set) … :与另外一BitSet相应的逻辑位运算it

  • String toString() :返回值为“true”的位置的String对象,如第1和第10位为“true”,其余位置为“false”,则返回{1, 10}方法

相关文章
相关标签/搜索
本站公众号
   欢迎关注本站公众号,获取更多信息