⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qbitarray.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    \sa clearBit() toggleBit()*//*!    Clears the bit at position \a index, i.e. sets it to 0.    \sa setBit(), toggleBit()*/void QBitArray::clearBit( uint index ){#if defined(QT_CHECK_RANGE)    if ( index >= size() ) {	qWarning( "QBitArray::clearBit: Index %d out of range", index );	return;    }#endif    *(data()+(index>>3)) &= ~(1 << (index & 7));}/*!    Toggles the bit at position \a 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.    \sa setBit(), clearBit()*/bool QBitArray::toggleBit( uint index ){#if defined(QT_CHECK_RANGE)    if ( index >= size() ) {	qWarning( "QBitArray::toggleBit: Index %d out of range", index );	return FALSE;    }#endif    register uchar *p = (uchar *)data() + (index>>3);    uchar b = (1 << (index & 7));		// bit position    uchar c = *p & b;				// read bit    *p ^= b;					// toggle bit    return c;}/*!    \fn bool QBitArray::at( uint index ) const    Returns the value (0 or 1) of the bit at position \a index.    \sa operator[]()*//*!    \fn QBitVal QBitArray::operator[]( int index )    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 \a index position.    Example:    \code    QBitArray a( 3 );    a[0] = 0;    a[1] = 1;    a[2] = a[0] ^ a[1];    \endcode    The functions testBit(), setBit() and clearBit() are faster.    \sa at()*//*!    \overload bool QBitArray::operator[]( int index ) const    Implements the [] operator for constant bit arrays.*//*!    Performs the AND operation between all bits in this bit array and    \a 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.    \code    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]    \endcode    \sa operator|=(), operator^=(), operator~()*/QBitArray &QBitArray::operator&=( const QBitArray &a ){    resize( QMAX(size(), a.size()) );    register uchar *a1 = (uchar *)data();    register uchar *a2 = (uchar *)a.data();    int n = QMIN( QByteArray::size(), a.QByteArray::size() );    int p = QMAX( QByteArray::size(), a.QByteArray::size() ) - n;    while ( n-- > 0 )	*a1++ &= *a2++;    while ( p-- > 0 )	*a1++ = 0;    return *this;}/*!    Performs the OR operation between all bits in this bit array and    \a 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.    \code    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]    \endcode    \sa operator&=(), operator^=(), operator~()*/QBitArray &QBitArray::operator|=( const QBitArray &a ){    resize( QMAX(size(), a.size()) );    register uchar *a1 = (uchar *)data();    register uchar *a2 = (uchar *)a.data();    int n = QMIN( QByteArray::size(), a.QByteArray::size() );    while ( n-- > 0 )	*a1++ |= *a2++;    return *this;}/*!    Performs the XOR operation between all bits in this bit array and    \a 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.    \code    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]    \endcode    \sa operator&=(), operator|=(), operator~()*/QBitArray &QBitArray::operator^=( const QBitArray &a ){    resize( QMAX(size(), a.size()) );    register uchar *a1 = (uchar *)data();    register uchar *a2 = (uchar *)a.data();    int n = QMIN( QByteArray::size(), a.QByteArray::size() );    while ( n-- > 0 )	*a1++ ^= *a2++;    return *this;}/*!    Returns a bit array that contains the inverted bits of this bit array.    Example:    \code    QBitArray a( 3 ), b;    a[0] = 1;  a[1] = 0; a[2] = 1;	// a = [1 0 1]    b = ~a;				// b = [0 1 0]    \endcode*/QBitArray QBitArray::operator~() const{    QBitArray a( size() );    register uchar *a1 = (uchar *)data();    register uchar *a2 = (uchar *)a.data();    int n = QByteArray::size();    while ( n-- )	*a2++ = ~*a1++;    a.pad0();    return a;}/*!    \relates QBitArray    Returns the AND result between the bit arrays \a a1 and \a 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.    \sa QBitArray::operator&=()*/QBitArray operator&( const QBitArray &a1, const QBitArray &a2 ){    QBitArray tmp = a1.copy();    tmp &= a2;    return tmp;}/*!    \relates QBitArray    Returns the OR result between the bit arrays \a a1 and \a 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.    \sa QBitArray::operator|=()*/QBitArray operator|( const QBitArray &a1, const QBitArray &a2 ){    QBitArray tmp = a1.copy();    tmp |= a2;    return tmp;}/*!    \relates QBitArray    Returns the XOR result between the bit arrays \a a1 and \a 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.    \sa QBitArray::operator^()*/QBitArray operator^( const QBitArray &a1, const QBitArray &a2 ){    QBitArray tmp = a1.copy();    tmp ^= a2;    return tmp;}/* \enum QGArray::array_data  \warning This will be renamed in the next major release of Qt.  Until  then it is undocumented and we recommend against its use.  \internal  ### 3.0 rename ###  ### 3.0 move it to QGArray? ###*//*!    \fn QBitArray::array_data * QBitArray::newData()    \internal    Returns data specific to QBitArray that extends what QGArray provides.    QPtrCollection mechanism for allowing extra/different data.*//*!    \fn void  QBitArray::deleteData ( array_data * d )    \internal    Deletes data specific to QBitArray that extended what QGArray provided.    QPtrCollection mechanism for allowing extra/different data.*//*****************************************************************************  QBitArray stream functions *****************************************************************************//*!    \relates QBitArray    Writes bit array \a a to stream \a s.    \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/#ifndef QT_NO_DATASTREAMQDataStream &operator<<( QDataStream &s, const QBitArray &a ){    Q_UINT32 len = a.size();    s << len;					// write size of array    if ( len > 0 )				// write data	s.writeRawBytes( a.data(), a.QByteArray::size() );    return s;}/*!    \relates QBitArray    Reads a bit array into \a a from stream \a s.    \sa \link datastreamformat.html Format of the QDataStream operators \endlink*/QDataStream &operator>>( QDataStream &s, QBitArray &a ){    Q_UINT32 len;    s >> len;					// read size of array    if ( !a.resize( (uint)len ) ) {		// resize array#if defined(QT_CHECK_NULL)	qWarning( "QDataStream: Not enough memory to read QBitArray" );#endif	len = 0;    }    if ( len > 0 )				// read data	s.readRawBytes( a.data(), a.QByteArray::size() );    return s;}#endif // QT_NO_DATASTREAM

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -