Homepage > Man Pages > Category > Subroutines

Homepage > Man Pages > Name > Q# qbitarray

## man page of qbitarray

### qbitarray: Array of bits

Homepage > Man Pages > Name > Q

NAME

QBitArray- Array of bits## SYNOPSIS

All the functions in this class are reentrant when Qt is built with thread support.</p> #include <qbitarray.h> Inherits QByteArray.Public Members QBitArray()QBitArray( uint size )QBitArray( const QBitArray & a )QBitArray & operator=( const QBitArray & a )uint size() constbool resize( uint size )bool fill( bool v, int size = -1 )virtual void detach()QBitArray copy() constbool testBit( uint index ) constvoid setBit( uint index )void setBit( uint index, bool value )void clearBit( uint index )bool toggleBit( uint index )bool at( uint index ) constQBitVal operator[]( int index )bool operator[]( int index ) constQBitArray & operator&=( const QBitArray & a )QBitArray & operator|=( const QBitArray & a )QBitArray & operator^=( const QBitArray & a )QBitArray operator~() const## RELATED FUNCTION DOCUMENTATION

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 )## DESCRIPTION

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. See also Collection Classes, Implicitly and Explicitly Shared Classes, and Non-GUI Classes.## MEMBER FUNCTION DOCUMENTATION

## QBITARRAY::QBITARRAY ()

Constructs an empty bit array.QBITARRAY::QBITARRAY ( UINT SIZE )

Constructs a bit array ofsizebits. The bits are uninitialized. See also fill().## QBITARRAY::QBITARRAY ( CONST QBITARRAY & A )

Constructs a shallow copy ofa.## BOOL QBITARRAY::AT ( UINT INDEX ) CONST

Returns the value (0 or 1) of the bit at positionindex. See also operator[]().## VOID QBITARRAY::CLEARBIT ( UINT INDEX )

Clears the bit at positionindex, i.e. sets it to 0. See also setBit() and toggleBit().## QBITARRAY QBITARRAY::COPY () CONST

Returns a deep copy of the bit array. See also detach().## VOID QBITARRAY::DETACH () [VIRTUAL]

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. See also copy(). Reimplemented from QMemArray.BOOL QBITARRAY::FILL ( BOOL V, INT SIZE = -1 )

Fills the bit array withv(1's ifvis TRUE, or 0's ifvis FALSE). fill() resizes the bit array tosizebits ifsizeis nonnegative. Returns FALSE if a nonnegativesizewas specified and the bit array could not be resized; otherwise returns TRUE. See also resize().## QBITARRAY & QBITARRAY::OPERATOR&= ( CONST QBITARRAY & A )

Performs the AND operation between all bits in this bit array anda. 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] See also operator|=(), operator^=(), and operator~().## QBITARRAY & QBITARRAY::OPERATOR= ( CONST QBITARRAY & A )

Assigns a shallow copy ofato this bit array and returns a reference to this array.## 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 itsindexposition. Example: QBitArray a( 3 ); a[0] = 0; a[1] = 1; a[2] = a[0] ^ a[1]; The functions testBit(), setBit() and clearBit() are faster. See also at().## BOOL QBITARRAY::OPERATOR[] ( INT INDEX ) CONST

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Implements the [] operator for constant bit arrays.## QBITARRAY & QBITARRAY::OPERATOR^= ( CONST QBITARRAY & A )

Performs the XOR operation between all bits in this bit array anda. 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] See also operator&=(), operator|=(), and operator~().QBITARRAY & QBITARRAY::OPERATOR|= ( CONST QBITARRAY & A )

Performs the OR operation between all bits in this bit array anda. 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] See also operator&=(), operator^=(), and operator~().## 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 tosizebits and returns TRUE if the bit array could be resized; otherwise returns FALSE. The array becomes a null array ifsize== 0. If the array is expanded, the new bits are set to 0. See also size().## VOID QBITARRAY::SETBIT ( UINT INDEX, BOOL VALUE )

Sets the bit at positionindextovalue. Equivalent to: if ( value ) setBit( index ); else clearBit( index ); See also clearBit() and toggleBit().## VOID QBITARRAY::SETBIT ( UINT INDEX )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Sets the bit at positionindexto 1. See also clearBit() and toggleBit().## UINT QBITARRAY::SIZE () CONST

Returns the bit array's size (number of bits). See also resize().BOOL QBITARRAY::TESTBIT ( UINT INDEX ) CONST

Returns TRUE if the bit at positionindexis set, i.e. is 1; otherwise returns FALSE. See also setBit() and clearBit().## BOOL QBITARRAY::TOGGLEBIT ( UINT INDEX )

Toggles the bit at positionindex. If the previous value was 0, the new value will be 1. If the previous value was 1, the new value will be 0. See also setBit() and clearBit().## RELATED FUNCTION DOCUMENTATION

## QBITARRAY OPERATOR& ( CONST QBITARRAY & A1, CONST QBITARRAY & A2 )

Returns the AND result between the bit arraysa1anda2. 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. See also QBitArray::operator&=().## QDATASTREAM & OPERATOR<< ( QDATASTREAM & S, CONST QBITARRAY & A )

Writes bit arrayato streams. See also Format of the QDataStream operators.## QDATASTREAM & OPERATOR>> ( QDATASTREAM & S, QBITARRAY & A )

Reads a bit array intoafrom streams. See also Format of the QDataStream operators.QBITARRAY OPERATOR^ ( CONST QBITARRAY & A1, CONST QBITARRAY & A2 )

Returns the XOR result between the bit arraysa1anda2. 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. See also QBitArray::operator^().## QBITARRAY OPERATOR| ( CONST QBITARRAY & A1, CONST QBITARRAY & A2 )

Returns the OR result between the bit arraysa1anda2. 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. See also QBitArray::operator|=().## SEE ALSO

//doc.trolltech.com/qbitarray.html //www.trolltech.com/faq/tech.html## COPYRIGHT

Copyright 1992-2007 Trolltech ASA, //www.trolltech.com. See the license file included in the distribution for a complete license statement.## AUTHOR

Generated automatically from the source code.## BUGS

If you find a bug in Qt, please report it as described in //doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt- bugs@trolltech.com. Please include the name of the manual page (qbitarray.3qt) and the Qt version (3.3.8). QBITARRAY(3)

Copyright © 2011–2018 by topics-of-interest.com . All rights reserved. Hosted by all-inkl.

Contact · Imprint · Privacy

Page generated in 30.17ms.

www.daelim-wiki.de | amazing-wings.de | adsenseexperts.com