#include </home/clem/local/src/opie/qmake/include/qbitarray.h>
Inheritance diagram for QBitArray:


Public Member Functions | |
| QBitArray () | |
| QBitArray (uint size) | |
| QBitArray (const QBitArray &a) | |
| QBitArray & | operator= (const QBitArray &) |
| uint | size () const |
| bool | resize (uint size) |
| bool | fill (bool v, int size=-1) |
| void | detach () |
| QBitArray | copy () const |
| bool | testBit (uint index) const |
| void | setBit (uint index) |
| void | setBit (uint index, bool value) |
| void | clearBit (uint index) |
| bool | toggleBit (uint index) |
| bool | at (uint index) const |
| QBitVal | operator[] (int index) |
| bool | operator[] (int index) const |
| QBitArray & | operator &= (const QBitArray &) |
| QBitArray & | operator|= (const QBitArray &) |
| QBitArray & | operator^= (const QBitArray &) |
| QBitArray | operator~ () const |
Protected Member Functions | |
| array_data * | newData () |
| void | deleteData (array_data *d) |
Private Member Functions | |
| void | pad0 () |
Related Functions | |
| (Note that these are not member functions.) | |
| QBitArray | operator & (const QBitArray &a1, const QBitArray &a2) |
| QBitArray | operator| (const QBitArray &a1, const QBitArray &a2) |
| QBitArray | operator^ (const QBitArray &a1, const QBitArray &a2) |
| QDataStream & | operator<< (QDataStream &s, const QBitArray &a) |
| QDataStream & | operator>> (QDataStream &s, QBitArray &a) |
Classes | |
| struct | bitarr_data |
| The QBitArray::bitarr_data class is internal. More... | |
Because QBitArray is a QMemArray, it uses explicit sharing with a reference count.
A QBitArray is a special byte array that can access individual bits and perform bit-operations (AND, OR, XOR and NOT) on entire arrays or bits.
Bits can be manipulated by the setBit() and clearBit() functions, but it is also possible to use the indexing [] operator to test and set individual bits. The [] operator is a little slower than setBit() and clearBit() because some tricks are required to implement single-bit assignments.
Example:
QBitArray a(3); a.setBit( 0 ); a.clearBit( 1 ); a.setBit( 2 ); // a = [1 0 1] QBitArray b(3); b[0] = 1; b[1] = 1; b[2] = 0; // b = [1 1 0] QBitArray c; c = ~a & b; // c = [0 1 0]
When a QBitArray is constructed the bits are uninitialized. Use fill() to set all the bits to 0 or 1. The array can be resized with resize() and copied with copy(). Bits can be set with setBit() and cleared with clearBit(). Bits can be toggled with toggleBit(). A bit's value can be obtained with testBit() and with at().
QBitArray supports the & (AND), | (OR), ^ (XOR) and ~ (NOT) operators.
Definition at line 69 of file qbitarray.h.
|
|
Constructs an empty bit array. Definition at line 142 of file qbitarray.cpp. References QBitArray::bitarr_data::nbits, and Opie::MM::x. |
|
|
Constructs a bit array of size bits. The bits are uninitialized.
Definition at line 156 of file qbitarray.cpp. References QBitArray::bitarr_data::nbits, resize(), and Opie::MM::x. |
|
|
Constructs a shallow copy of a. Definition at line 74 of file qbitarray.h. |
|
|
Returns the value (0 or 1) of the bit at position index.
Definition at line 121 of file qbitarray.h. References testBit(). |
|
|
Clears the bit at position index, i.e. sets it to 0.
Definition at line 344 of file qbitarray.cpp. References data, qWarning(), and size(). Referenced by Referee::demo(), Referee::introPlay(), Referee::killedPlay(), Referee::levelUpPlay(), Referee::pause(), Referee::ready(), setBit(), and Referee::start(). |
|
|
Returns a deep copy of the bit array.
Definition at line 276 of file qbitarray.cpp. References SHBLOCK. Referenced by operator &(), operator^(), and operator|(). |
|
|
For internal use only. Deletes data specific to QBitArray that extended what QGArray provided. QPtrCollection mechanism for allowing extra/different data. Definition at line 106 of file qbitarray.h. |
|
|
Detaches from shared bit array data and makes sure that this bit array is the only one referring to the data. If multiple bit arrays share common data, this bit array dereferences the data and gets a copy of the data. Nothing happens if there is only a single reference.
Definition at line 263 of file qbitarray.cpp. References SHBLOCK. |
|
||||||||||||
|
Fills the bit array with v (1's if v is TRUE, or 0's if v is FALSE). fill() resizes the bit array to size bits if size is nonnegative. Returns FALSE if a nonnegative size was specified and the bit array could not be resized; otherwise returns TRUE.
Definition at line 236 of file qbitarray.cpp. References data, FALSE, pad0(), resize(), size(), and TRUE. Referenced by Referee::demo(), Referee::intro(), QRegExpEngine::matchHere(), Referee::play(), OTodoAccessXML::sup(), OTodoAccessVCal::sup(), and OTodoAccessBackendSQL::sup(). |
|
|
For internal use only. Returns data specific to QBitArray that extends what QGArray provides. QPtrCollection mechanism for allowing extra/different data. Definition at line 105 of file qbitarray.h. |
|
|
Performs the AND operation between all bits in this bit array and a. Returns a reference to this bit array. The result has the length of the longest of the two bit arrays, with any missing bits (i.e. if one array is shorter than the other), taken to be 0. QBitArray a( 3 ), b( 2 ); a[0] = 1; a[1] = 0; a[2] = 1; // a = [1 0 1] b[0] = 1; b[1] = 0; // b = [1 0] a &= b; // a = [1 0 0]
Definition at line 433 of file qbitarray.cpp. |
|
|
Assigns a shallow copy of a to this bit array and returns a reference to this array. Definition at line 112 of file qbitarray.h. |
|
|
Definition at line 127 of file qbitarray.h. References testBit(). |
|
|
Implements the [] operator for bit arrays. The returned QBitVal is a context object. It makes it possible to get and set a single bit value by its index position. Example: QBitArray a( 3 ); a[0] = 0; a[1] = 1; a[2] = a[0] ^ a[1]; The functions testBit(), setBit() and clearBit() are faster.
Definition at line 124 of file qbitarray.h. |
|
|
Performs the XOR operation between all bits in this bit array and a. Returns a reference to this bit array. The result has the length of the longest of the two bit arrays, with any missing bits (i.e. if one array is shorter than the other), taken to be 0. QBitArray a( 3 ), b( 2 ); a[0] = 1; a[1] = 0; a[2] = 1; // a = [1 0 1] b[0] = 1; b[1] = 0; // b = [1 0] a ^= b; // a = [0 0 1]
Definition at line 492 of file qbitarray.cpp. |
|
|
Performs the OR operation between all bits in this bit array and a. Returns a reference to this bit array. The result has the length of the longest of the two bit arrays, with any missing bits (i.e. if one array is shorter than the other), taken to be 0. QBitArray a( 3 ), b( 2 ); a[0] = 1; a[1] = 0; a[2] = 1; // a = [1 0 1] b[0] = 1; b[1] = 0; // b = [1 0] a |= b; // a = [1 0 1]
Definition at line 464 of file qbitarray.cpp. |
|
|
Returns a bit array that contains the inverted bits of this bit array. Example: QBitArray a( 3 ), b; a[0] = 1; a[1] = 0; a[2] = 1; // a = [1 0 1] b = ~a; // b = [0 1 0] Definition at line 514 of file qbitarray.cpp. |
|
|
Pad last byte with 0-bits. Definition at line 182 of file qbitarray.cpp. Referenced by fill(), and operator~(). |
|
|
Resizes the bit array to size bits and returns TRUE if the bit array could be resized; otherwise returns FALSE. The array becomes a null array if size == 0. If the array is expanded, the new bits are set to 0.
Definition at line 208 of file qbitarray.cpp. References data, FALSE, s, SHBLOCK, size(), and TRUE. Referenced by fill(), Opie::MM::OImageScrollView::OImageScrollView(), operator &=(), operator>>(), operator^=(), operator|=(), QBitArray(), and Referee::Referee(). |
|
||||||||||||
|
Sets the bit at position index to value. Equivalent to:
Definition at line 118 of file qbitarray.h. References clearBit(), and setBit(). |
|
|
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the bit at position index to 1.
Definition at line 311 of file qbitarray.cpp. References data, qWarning(), and size(). Referenced by Referee::demo(), Referee::eaten(), Referee::intro(), Referee::killed(), Referee::killedPlay(), Referee::levelUp(), Referee::levelUpPlay(), QRegExpEngine::matchHere(), QBitVal::operator=(), IMAPwrapper::parse_list_result(), Genericwrapper::parseList(), Referee::pause(), Referee::play(), Referee::ready(), Opie::MM::OImageScrollView::setAutoRotate(), Opie::MM::OImageScrollView::setAutoScale(), Opie::MM::OImageScrollView::setAutoScaleRotate(), setBit(), Opie::MM::OImageScrollView::setFirstResizeDone(), Opie::MM::OImageScrollView::setImageIsJpeg(), Opie::MM::OImageScrollView::setImageScaledLoaded(), and Opie::MM::OImageScrollView::setShowZoomer(). |
|
|
Returns the bit array's size (number of bits).
Definition at line 115 of file qbitarray.h. Referenced by clearBit(), fill(), operator &=(), operator<<(), operator^=(), operator|=(), operator~(), pad0(), resize(), setBit(), testBit(), and toggleBit(). |
|
|
|
Toggles the bit at position index. If the previous value was 0, the new value will be 1. If the previous value was 1, the new value will be 0.
Definition at line 364 of file qbitarray.cpp. References data, FALSE, p, qWarning(), and size(). Referenced by Referee::toggleHallOfFame(). |
|
||||||||||||
|
Returns the AND result between the bit arrays a1 and a2. The result has the length of the longest of the two bit arrays, with any missing bits (i.e. if one array is shorter than the other), taken to be 0.
Definition at line 539 of file qbitarray.cpp. References copy(). |
|
||||||||||||
|
Writes bit array a to stream s.
Definition at line 630 of file qbitarray.cpp. References len, size(), and QDataStream::writeRawBytes(). |
|
||||||||||||
|
Reads a bit array into a from stream s.
Definition at line 647 of file qbitarray.cpp. References len, qWarning(), QDataStream::readRawBytes(), and resize(). |
|
||||||||||||
|
Returns the XOR result between the bit arrays a1 and a2. The result has the length of the longest of the two bit arrays, with any missing bits (i.e. if one array is shorter than the other), taken to be 0.
Definition at line 577 of file qbitarray.cpp. References copy(). |
|
||||||||||||
|
Returns the OR result between the bit arrays a1 and a2. The result has the length of the longest of the two bit arrays, with any missing bits (i.e. if one array is shorter than the other), taken to be 0.
Definition at line 558 of file qbitarray.cpp. References copy(). |
1.4.2