Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtCore.QBitArray Class Reference

The QBitArray class provides an array of bits. More...

Inheritance diagram for QtCore.QBitArray:
Collaboration diagram for QtCore.QBitArray:

Public Member Functions

override bool Equals (object o)
 
override int GetHashCode ()
 
 QBitArray ()
 
 
 QBitArray (QBitArray other)
 
 
 QBitArray (int size, bool val=false)
 
 
virtual void CreateProxy ()
 
new bool At (int i)
 
 
new void Clear ()
 
 
new void ClearBit (int i)
 
 
new int Count ()
 
 
new int Count (bool on)
 
 
new void Detach ()
 
new bool Fill (bool val, int size=-1)
 
 
new void Fill (bool val, int first, int last)
 
 
new bool IsDetached ()
 
new bool IsEmpty ()
 
 
new bool IsNull ()
 
 
new void Resize (int size)
 
 
new void SetBit (int i)
 
 
new void SetBit (int i, bool val)
 
 
new int Size ()
 
 
new void Swap (QBitArray other)
 
 
new bool TestBit (int i)
 
 
new bool ToggleBit (int i)
 
 
new void Truncate (int pos)
 
 
new void Dispose ()
 

Static Public Member Functions

static bool operator!= (QBitArray arg1, QBitArray arg2)
 
 
static bool operator== (QBitArray arg1, QBitArray arg2)
 
 
static QBitArray operator~ (QBitArray arg1)
 
 
static QBitArray operator& (QBitArray arg1, QBitArray arg2)
 
 
static QBitArray operator^ (QBitArray arg1, QBitArray arg2)
 
 
static QBitArray operator| (QBitArray arg1, QBitArray arg2)
 
 

Protected Member Functions

 QBitArray (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

The QBitArray class provides an array of bits.

A QBitArray is an array that gives access to individual bits and provides operators (AND, OR, XOR, and NOT) that work on entire arrays of bits. It uses implicit sharing (copy-on-write) to reduce memory usage and to avoid the needless copying of data.

The following code constructs a QBitArray containing 200 bits initialized to false (0):

QBitArray ba(200);

To initialize the bits to true, either pass true as second argument to the constructor, or call fill() later on.

QBitArray uses 0-based indexes, just like C++ arrays. To access the bit at a particular index position, you can use operator[](). On non-const bit arrays, operator[]() returns a reference to a bit that can be used on the left side of an assignment. For example:

QBitArray ba;

ba.resize(3);

ba[0] = true;

ba[1] = false;

ba[2] = true;

For technical reasons, it is more efficient to use testBit() and setBit() to access bits in the array than operator[](). For example:

QBitArray ba(3);

ba.setBit(0, true);

ba.setBit(1, false);

ba.setBit(2, true);

QBitArray supports & (AND), | (OR), ^ (XOR), ~ (NOT), as well as &=, |=, and ^=. These operators work in the same way as the built-in C++ bitwise operators of the same name. For example:

QBitArray x(5);

x.setBit(3, true);

// x: [ 0, 0, 0, 1, 0 ]

QBitArray y(5);

y.setBit(4, true);

// y: [ 0, 0, 0, 0, 1 ]

x |= y;

// x: [ 0, 0, 0, 1, 1 ]

For historical reasons, QBitArray distinguishes between a null bit array and an empty bit array. A null bit array is a bit array that is initialized using QBitArray's default constructor. An empty bit array is any bit array with size 0. A null bit array is always empty, but an empty bit array isn't necessarily null:

QBitArray().isNull(); // returns true

QBitArray().isEmpty(); // returns true

QBitArray(0).isNull(); // returns false

QBitArray(0).isEmpty(); // returns true

QBitArray(3).isNull(); // returns false

QBitArray(3).isEmpty(); // returns false

All functions except isNull() treat null bit arrays the same as empty bit arrays; for example, QBitArray() compares equal to QBitArray(0). We recommend that you always use isEmpty() and avoid isNull().

See also QByteArray and QVector.

Constructor & Destructor Documentation

QtCore.QBitArray.QBitArray ( System.Type  dummy)
protected
QtCore.QBitArray.QBitArray ( )

Constructs an empty bit array.

See also isEmpty().

QtCore.QBitArray.QBitArray ( QBitArray  other)

Constructs a copy of other.

This operation takes constant time, because QBitArray is implicitly shared. This makes returning a QBitArray from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

See also operator=().

QtCore.QBitArray.QBitArray ( int  size,
bool  val = false 
)

Constructs a bit array containing size bits. The bits are initialized with value, which defaults to false (0).

Member Function Documentation

new bool QtCore.QBitArray.At ( int  i)

Returns the value of the bit at index position i.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also operator[]().

new void QtCore.QBitArray.Clear ( )

Clears the contents of the bit array and makes it empty.

See also resize() and isEmpty().

new void QtCore.QBitArray.ClearBit ( int  i)

Sets the bit at index position i to 0.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also setBit() and toggleBit().

new int QtCore.QBitArray.Count ( )

Same as size().

new int QtCore.QBitArray.Count ( bool  on)

If on is true, this function returns the number of 1-bits stored in the bit array; otherwise the number of 0-bits is returned.

virtual void QtCore.QBitArray.CreateProxy ( )
virtual
new void QtCore.QBitArray.Detach ( )
new void QtCore.QBitArray.Dispose ( )
override bool QtCore.QBitArray.Equals ( object  o)
new bool QtCore.QBitArray.Fill ( bool  val,
int  size = -1 
)

Sets every bit in the bit array to value, returning true if successful; otherwise returns false. If size is different from -1 (the default), the bit array is resized to size beforehand.

Example:

QBitArray ba(8);

ba.fill(true);

// ba: [ 1, 1, 1, 1, 1, 1, 1, 1 ]

ba.fill(false, 2);

// ba: [ 0, 0 ]

See also resize().

new void QtCore.QBitArray.Fill ( bool  val,
int  first,
int  last 
)

This is an overloaded function.

Sets bits at index positions begin up to and excluding end to value.

begin and end must be a valid index position in the bit array (i.e., 0 <= begin <= size() and 0 <= end <= size()).

override int QtCore.QBitArray.GetHashCode ( )
new bool QtCore.QBitArray.IsDetached ( )
new bool QtCore.QBitArray.IsEmpty ( )

Returns true if this bit array has size 0; otherwise returns false.

See also size().

new bool QtCore.QBitArray.IsNull ( )

Returns true if this bit array is null; otherwise returns false.

Example:

QBitArray().isNull(); // returns true

QBitArray(0).isNull(); // returns false

QBitArray(3).isNull(); // returns false

Qt makes a distinction between null bit arrays and empty bit arrays for historical reasons. For most applications, what matters is whether or not a bit array contains any data, and this can be determined using isEmpty().

See also isEmpty().

static bool QtCore.QBitArray.operator!= ( QBitArray  arg1,
QBitArray  arg2 
)
static

Returns true if other is not equal to this bit array; otherwise returns false.

See also operator==().

static QBitArray QtCore.QBitArray.operator& ( QBitArray  arg1,
QBitArray  arg2 
)
static

Returns a bit array that is the AND of the bit arrays a1 and a2.

The result has the length of the longest of the two bit arrays, with any missing bits (if one array is shorter than the other) taken to be 0.

Example:

QBitArray a(3);

QBitArray b(2);

QBitArray c;

a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]

b[0] = 1; b[1] = 0; // b: [ 1, 1 ]

c = a & b; // c: [ 1, 0, 0 ]

See also QBitArray::operator&amp;=(), operator|(), and operator^().

static bool QtCore.QBitArray.operator== ( QBitArray  arg1,
QBitArray  arg2 
)
static

Returns true if other is equal to this bit array; otherwise returns false.

See also operator!=().

static QBitArray QtCore.QBitArray.operator^ ( QBitArray  arg1,
QBitArray  arg2 
)
static

Returns a bit array that is the XOR of the bit arrays a1 and a2.

The result has the length of the longest of the two bit arrays, with any missing bits (if one array is shorter than the other) taken to be 0.

Example:

QBitArray a(3);

QBitArray b(2);

QBitArray c;

a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]

b[0] = 1; b[1] = 0; // b: [ 1, 1 ]

c = a ^ b; // c: [ 0, 1, 1 ]

See also QBitArray::operator^=(), operator&(), and operator|().

static QBitArray QtCore.QBitArray.operator| ( QBitArray  arg1,
QBitArray  arg2 
)
static

Returns a bit array that is the OR of the bit arrays a1 and a2.

The result has the length of the longest of the two bit arrays, with any missing bits (if one array is shorter than the other) taken to be 0.

Example:

QBitArray a(3);

QBitArray b(2);

QBitArray c;

a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]

b[0] = 1; b[1] = 0; // b: [ 1, 1 ]

c = a | b; // c: [ 1, 1, 1 ]

See also QBitArray::operator|=(), operator&(), and operator^().

static QBitArray QtCore.QBitArray.operator~ ( QBitArray  arg1)
static

Returns a bit array that contains the inverted bits of this bit array.

Example:

QBitArray a(3);

QBitArray b;

a[0] = 1; a[1] = 0; a[2] = 1; // a: [ 1, 0, 1 ]

b = ~a; // b: [ 0, 1, 0 ]

See also operator&(), operator|(), and operator^().

new void QtCore.QBitArray.Resize ( int  size)

Resizes the bit array to size bits.

If size is greater than the current size, the bit array is extended to make it size bits with the extra bits added to the end. The new bits are initialized to false (0).

If size is less than the current size, bits are removed from the end.

See also size().

new void QtCore.QBitArray.SetBit ( int  i)

Sets the bit at index position i to 1.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also clearBit() and toggleBit().

new void QtCore.QBitArray.SetBit ( int  i,
bool  val 
)

This is an overloaded function.

Sets the bit at index position i to value.

new int QtCore.QBitArray.Size ( )

Returns the number of bits stored in the bit array.

See also resize().

new void QtCore.QBitArray.Swap ( QBitArray  other)

Swaps bit array other with this bit array. This operation is very fast and never fails.

This function was introduced in Qt 4.8.

new bool QtCore.QBitArray.TestBit ( int  i)

Returns true if the bit at index position i is 1; otherwise returns false.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also setBit() and clearBit().

new bool QtCore.QBitArray.ToggleBit ( int  i)

Inverts the value of the bit at index position i, returning the previous value of that bit as either true (if it was set) or false (if it was unset).

If the previous value was 0, the new value will be 1. If the previous value was 1, the new value will be 0.

i must be a valid index position in the bit array (i.e., 0 <= i < size()).

See also setBit() and clearBit().

new void QtCore.QBitArray.Truncate ( int  pos)

Truncates the bit array at index position pos.

If pos is beyond the end of the array, nothing happens.

See also resize().

Member Data Documentation

SmokeInvocation QtCore.QBitArray.interceptor
protected

Property Documentation

virtual System.IntPtr QtCore.QBitArray.SmokeObject
getset