Eneboo - Documentación para desarrolladores
Clases | Métodos públicos | Métodos protegidos | Funciones relacionadas
Referencia de la Clase QBitArray

The QBitArray class provides an array of bits. Más...

#include <qbitarray.h>

Diagrama de herencias de QBitArray
QByteArray QByteArray QwtPlotCurve::PrivateData::PixelMatrix

Lista de todos los miembros.

Clases

class  bitarr_data
 The QBitArray::bitarr_data class is internal. Más...

Métodos públicos

 QBitArray ()
 QBitArray (uint size)
 QBitArray (const QBitArray &a)
QBitArrayoperator= (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
QBitArrayoperator&= (const QBitArray &)
QBitArrayoperator|= (const QBitArray &)
QBitArrayoperator^= (const QBitArray &)
QBitArray operator~ () const
 QBitArray ()
 QBitArray (uint size)
 QBitArray (const QBitArray &a)
QBitArrayoperator= (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
QBitArrayoperator&= (const QBitArray &)
QBitArrayoperator|= (const QBitArray &)
QBitArrayoperator^= (const QBitArray &)
QBitArray operator~ () const

Métodos protegidos

array_data * newData ()
void deleteData (array_data *d)
array_data * newData ()
void deleteData (array_data *d)

Funciones relacionadas

(Observar que estas no son funciones miembro.)

QBitArray operator& (const QBitArray &a1, const QBitArray &a2)
QBitArray operator| (const QBitArray &a1, const QBitArray &a2)
QBitArray operator^ (const QBitArray &a1, const QBitArray &a2)
QDataStreamoperator<< (QDataStream &s, const QBitArray &a)
QDataStreamoperator>> (QDataStream &s, QBitArray &a)

Descripción detallada

The QBitArray class provides an array of bits.

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.


Documentación del constructor y destructor

QBitArray::QBitArray ( )

Constructs an empty bit array.

QBitArray::QBitArray ( uint  size)

Constructs a bit array of size bits. The bits are uninitialized.

Ver también:
fill()
QBitArray::QBitArray ( const QBitArray a) [inline]

Constructs a shallow copy of a.

QBitArray::QBitArray ( )
QBitArray::QBitArray ( uint  size)
QBitArray::QBitArray ( const QBitArray a) [inline]

Documentación de las funciones miembro

bool QBitArray::at ( uint  index) const [inline]

Returns the value (0 or 1) of the bit at position index.

Ver también:
operator[]()
bool QBitArray::at ( uint  index) const
void QBitArray::clearBit ( uint  index)

Clears the bit at position index, i.e. sets it to 0.

Ver también:
setBit(), toggleBit()
void QBitArray::clearBit ( uint  index)
QBitArray QBitArray::copy ( ) const

Returns a deep copy of the bit array.

Ver también:
detach()
QBitArray QBitArray::copy ( ) const
void QBitArray::deleteData ( array_data *  d) [inline, protected]
void QBitArray::deleteData ( array_data *  d) [inline, protected]
void QBitArray::detach ( )
void QBitArray::detach ( )

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.

Ver también:
copy()
bool QBitArray::fill ( bool  v,
int  size = -1 
)

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.

Ver también:
resize()
bool QBitArray::fill ( bool  v,
int  size = -1 
)
QBitArray::array_data * QBitArray::newData ( ) [inline, protected]
array_data* QBitArray::newData ( ) [inline, protected]
QBitArray& QBitArray::operator&= ( const QBitArray )
QBitArray & QBitArray::operator&= ( const QBitArray a)

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]
Ver también:
operator|=(), operator^=(), operator~()
QBitArray & QBitArray::operator= ( const QBitArray a) [inline]

Assigns a shallow copy of a to this bit array and returns a reference to this array.

QBitArray& QBitArray::operator= ( const QBitArray )
QBitVal QBitArray::operator[] ( int  index)
bool QBitArray::operator[] ( int  index) const
QBitVal QBitArray::operator[] ( int  index) [inline]

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.

Ver también:
at()
bool QBitArray::operator[] ( int  index) const [inline]
QBitArray& QBitArray::operator^= ( const QBitArray )
QBitArray & QBitArray::operator^= ( const QBitArray a)

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]
Ver también:
operator&=(), operator|=(), operator~()
QBitArray& QBitArray::operator|= ( const QBitArray )
QBitArray & QBitArray::operator|= ( const QBitArray a)

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]
Ver también:
operator&=(), operator^=(), operator~()
QBitArray QBitArray::operator~ ( ) const
QBitArray QBitArray::operator~ ( ) const

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]
bool QBitArray::resize ( uint  size)

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.

Ver también:
size()
bool QBitArray::resize ( uint  size)
void QBitArray::setBit ( uint  index,
bool  value 
)
void QBitArray::setBit ( uint  index)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Sets the bit at position index to 1.

Ver también:
clearBit() toggleBit()
void QBitArray::setBit ( uint  index,
bool  value 
) [inline]

Sets the bit at position index to value.

Equivalent to:

    if ( value )
        setBit( index );
    else
        clearBit( index );
Ver también:
clearBit() toggleBit()
void QBitArray::setBit ( uint  index)
uint QBitArray::size ( ) const [inline]

Returns the bit array's size (number of bits).

Ver también:
resize()
uint QBitArray::size ( ) const
bool QBitArray::testBit ( uint  index) const

Returns TRUE if the bit at position index is set, i.e. is 1; otherwise returns FALSE.

Ver también:
setBit(), clearBit()
bool QBitArray::testBit ( uint  index) const
bool QBitArray::toggleBit ( uint  index)
bool QBitArray::toggleBit ( uint  index)

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.

Ver también:
setBit(), clearBit()

Documentación de las funciones relacionadas y clases amigas

QBitArray operator& ( const QBitArray a1,
const QBitArray a2 
) [related]

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.

Ver también:
QBitArray::operator&=()
QDataStream & operator<< ( QDataStream s,
const QBitArray a 
) [related]

Writes bit array a to stream s.

Ver también:
Format of the QDataStream operators
QDataStream & operator>> ( QDataStream s,
QBitArray a 
) [related]

Reads a bit array into a from stream s.

Ver también:
Format of the QDataStream operators
QBitArray operator^ ( const QBitArray a1,
const QBitArray a2 
) [related]

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.

Ver también:
QBitArray::operator^()
QBitArray operator| ( const QBitArray a1,
const QBitArray a2 
) [related]

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.

Ver también:
QBitArray::operator|=()

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'