include<QBitArray>
公有函数:
QBitArray () |
|
| QBitArray ( int size , bool value = false ) | |
| QBitArray ( const QBitArray & other ) | |
| bool | at ( int i ) const |
| void | clear () |
| void | clearBit ( int i ) |
| int | count () const |
| int | count ( bool on ) const |
| bool | fill ( bool value , int size = -1 ) |
| void | fill ( bool value , int begin , int end ) |
| bool | isEmpty () const |
| bool | isNull () const |
| void | resize ( int size ) |
| void | setBit ( int i ) |
| void | setBit ( int i , bool value ) |
| int | size () const |
| bool | testBit ( int i ) const |
| bool | toggleBit ( int i ) |
| void | truncate ( int pos ) |
| bool | operator!= ( const QBitArray & other ) const |
| QBitArray & | operator&= ( const QBitArray & other ) |
| QBitArray & | operator= ( const QBitArray & other ) |
| bool | operator== ( const QBitArray & other ) const |
| QBitRef | operator[] ( int i ) |
| bool | operator[] ( int i ) const |
| QBitRef | operator[] ( uint i ) |
| bool | operator[] ( uint i ) const |
| QBitArray & | operator^= ( const QBitArray & other ) |
| QBitArray & | operator|= ( const QBitArray & other ) |
| QBitArray | operator~ () const |
涉及到得非成员函数:
| QBitArray | operator& ( const QBitArray & a1 , const QBitArray & a2 ) |
| QDataStream & | operator<< ( QDataStream & out , const QBitArray & ba ) |
| QDataStream & | operator>> ( QDataStream & in , QBitArray & ba ) |
| QBitArray | operator^ ( const QBitArray & a1 , const QBitArray & a2 ) |
| QBitArray | operator| ( const QBitArray & a1 , const QBitArray & a2 ) |
详细描述:
QBitArray类提供了一个位序列。
QBitArray类提供了访问序列中单独位的方法,也可以对序列中的位执行 与 、或、 非、异或操作(AND, OR ,NOT,XOR),提供隐式的内存共享机制,从而减少内存使用率和不必要的数据复制。
下面的代码初始化一个 QBitArray对象,包含200个数位(BITS),全部初始化为0,即FALSE:
<span style="font-family:SimHei;font-size:18px;">
</span>
<span style="font-family:SimHei;font-size:18px;"> 把QBitArray中的某个数位初始化为TRUE,或者传递第二个参数作为<strong>QBitArray的构造函数,如QBitArray ba(200,TRUE),或者在之后调用fill()函数。附注:在QBitArray中TRUE对应1,FALSE对应0.</strong></span>
QBitArray用0作为起始下标,这点类似于C++,当我们访问一个指定下标所对应的数位(BITS)时可以调用OPERATOR[]()。 在一个NON-CONST的位序列中,OPERATOR[]()返回一个可以用于左值的引用,例如:
出于性能考虑,当我们访问QBitArray中的指定位(BITS)时,testBit()和setBit()相对于OPERATOR[]()在性能上效率更高。例如:
QBitArray支持 &(AND) |(OR) ^(XOR) ~(NOT)操作,类似于&=,|=,^=.这些操作对应于C++按位访问的名称是一个意思。例如:出于历史原因,QBitArray是区分NULL和EMPTY的,NULL对应于默认构造函数中的一个位,EMPTY在SIZE()返回0时被设置,一个NULL位总是EMPTY,但相反就不一定。例如:
在所有的函数中只有isNull()对NULL和EMPTY做相同的处理,例如:QBitArray()和QBitArray(0)的执行效果是一样的,通常情况下,建议使用isEmpty(),而避免使用isNull().
Member Function Documentation:
//例如:count(true)+count(false)==count()==size()
//必须是一个有效的范围,否则会产生越界或者溢出。
出于历史原因,QT严格区分NULL和EMPTY,在大多数应用中,判断一个序列中是否包含有数据时,可以使用isEmpty()
//把参数i所指定的序列下标所对应的位值设置为1,参数i必须是一个有效的下标,否则会产生越界或溢出。
相对而言 testBit (), setBit (), and clearBit () 在执行效率上稍快一些。
//重载函数,不同的是参数i是unsigned int 的类型重定义。并返回可用于左值赋值的引用
//重载函数,不同的是参数是unsigned int
涉及到得非成员函数:
原文:http://www.cnblogs.com/lvdongjie/p/5000733.html