mscorlib(4.0.0.0) API with additions
System.Collections.BitArray Class Reference

Manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0). More...

Inheritance diagram for System.Collections.BitArray:
[legend]
Collaboration diagram for System.Collections.BitArray:
[legend]

Public Member Functions

 BitArray (int length)
 Initializes a new instance of the T:System.Collections.BitArray class that can hold the specified number of bit values, which are initially set to false. More...
 
 BitArray (int length, bool defaultValue)
 Initializes a new instance of the T:System.Collections.BitArray class that can hold the specified number of bit values, which are initially set to the specified value. More...
 
 BitArray (byte[] bytes)
 Initializes a new instance of the T:System.Collections.BitArray class that contains bit values copied from the specified array of bytes. More...
 
 BitArray (bool[] values)
 Initializes a new instance of the T:System.Collections.BitArray class that contains bit values copied from the specified array of Booleans. More...
 
 BitArray (int[] values)
 Initializes a new instance of the T:System.Collections.BitArray class that contains bit values copied from the specified array of 32-bit integers. More...
 
 BitArray (BitArray bits)
 Initializes a new instance of the T:System.Collections.BitArray class that contains bit values copied from the specified T:System.Collections.BitArray. More...
 
bool Get (int index)
 Gets the value of the bit at a specific position in the T:System.Collections.BitArray. More...
 
void Set (int index, bool value)
 Sets the bit at a specific position in the T:System.Collections.BitArray to the specified value. More...
 
void SetAll (bool value)
 Sets all bits in the T:System.Collections.BitArray to the specified value. More...
 
BitArray And (BitArray value)
 Performs the bitwise AND operation between the elements of the current T:System.Collections.BitArray object and the corresponding elements in the specified array. The current T:System.Collections.BitArray object will be modified to store the result of the bitwise AND operation. More...
 
BitArray Or (BitArray value)
 Performs the bitwise OR operation between the elements of the current T:System.Collections.BitArray object and the corresponding elements in the specified array. The current T:System.Collections.BitArray object will be modified to store the result of the bitwise OR operation. More...
 
BitArray Xor (BitArray value)
 Performs the bitwise exclusive OR operation between the elements of the current T:System.Collections.BitArray object against the corresponding elements in the specified array. The current T:System.Collections.BitArray object will be modified to store the result of the bitwise exclusive OR operation. More...
 
BitArray Not ()
 Inverts all the bit values in the current T:System.Collections.BitArray, so that elements set to true are changed to false, and elements set to false are changed to true. More...
 
void CopyTo (Array array, int index)
 Copies the entire T:System.Collections.BitArray to a compatible one-dimensional T:System.Array, starting at the specified index of the target array. More...
 
object Clone ()
 Creates a shallow copy of the T:System.Collections.BitArray. More...
 
IEnumerator GetEnumerator ()
 Returns an enumerator that iterates through the T:System.Collections.BitArray. More...
 

Public Attributes

int Count => m_length
 Gets the number of elements contained in the T:System.Collections.BitArray. More...
 
bool IsReadOnly => false
 Gets a value indicating whether the T:System.Collections.BitArray is read-only. More...
 
bool IsSynchronized => false
 Gets a value indicating whether access to the T:System.Collections.BitArray is synchronized (thread safe). More...
 

Properties

bool this[int index] [get, set]
 Gets or sets the value of the bit at a specific position in the T:System.Collections.BitArray. More...
 
int? Length [get, set]
 Gets or sets the number of elements in the T:System.Collections.BitArray. More...
 
object SyncRoot [get]
 Gets an object that can be used to synchronize access to the T:System.Collections.BitArray. More...
 
- Properties inherited from System.Collections.ICollection
int Count [get]
 Gets the number of elements contained in the T:System.Collections.ICollection. More...
 
object SyncRoot [get]
 Gets an object that can be used to synchronize access to the T:System.Collections.ICollection. More...
 
bool IsSynchronized [get]
 Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (thread safe). More...
 

Detailed Description

Manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0).

Definition at line 10 of file BitArray.cs.

Constructor & Destructor Documentation

◆ BitArray() [1/6]

System.Collections.BitArray.BitArray ( int  length)

Initializes a new instance of the T:System.Collections.BitArray class that can hold the specified number of bit values, which are initially set to false.

Parameters
lengthThe number of bit values in the new T:System.Collections.BitArray.
Exceptions
T:System.ArgumentOutOfRangeExceptionlength is less than zero.

Definition at line 190 of file BitArray.cs.

◆ BitArray() [2/6]

System.Collections.BitArray.BitArray ( int  length,
bool  defaultValue 
)

Initializes a new instance of the T:System.Collections.BitArray class that can hold the specified number of bit values, which are initially set to the specified value.

Parameters
lengthThe number of bit values in the new T:System.Collections.BitArray.
defaultValueThe Boolean value to assign to each bit.
Exceptions
T:System.ArgumentOutOfRangeExceptionlength is less than zero.

Definition at line 201 of file BitArray.cs.

◆ BitArray() [3/6]

System.Collections.BitArray.BitArray ( byte []  bytes)

Initializes a new instance of the T:System.Collections.BitArray class that contains bit values copied from the specified array of bytes.

Parameters
bytesAn array of bytes containing the values to copy, where each byte represents eight consecutive bits.
Exceptions
T:System.ArgumentNullExceptionbytes is null.
T:System.ArgumentExceptionThe length of bytes is greater than F:System.Int32.MaxValue.

Definition at line 223 of file BitArray.cs.

◆ BitArray() [4/6]

System.Collections.BitArray.BitArray ( bool []  values)

Initializes a new instance of the T:System.Collections.BitArray class that contains bit values copied from the specified array of Booleans.

Parameters
valuesAn array of Booleans to copy.
Exceptions
T:System.ArgumentNullExceptionvalues is null.

Definition at line 261 of file BitArray.cs.

◆ BitArray() [5/6]

System.Collections.BitArray.BitArray ( int []  values)

Initializes a new instance of the T:System.Collections.BitArray class that contains bit values copied from the specified array of 32-bit integers.

Parameters
valuesAn array of integers containing the values to copy, where each integer represents 32 consecutive bits.
Exceptions
T:System.ArgumentNullExceptionvalues is null.
T:System.ArgumentExceptionThe length of values is greater than F:System.Int32.MaxValue

Definition at line 285 of file BitArray.cs.

◆ BitArray() [6/6]

System.Collections.BitArray.BitArray ( BitArray  bits)

Initializes a new instance of the T:System.Collections.BitArray class that contains bit values copied from the specified T:System.Collections.BitArray.

Parameters
bitsThe T:System.Collections.BitArray to copy.
Exceptions
T:System.ArgumentNullExceptionbits is null.

Definition at line 306 of file BitArray.cs.

Member Function Documentation

◆ And()

BitArray System.Collections.BitArray.And ( BitArray  value)

Performs the bitwise AND operation between the elements of the current T:System.Collections.BitArray object and the corresponding elements in the specified array. The current T:System.Collections.BitArray object will be modified to store the result of the bitwise AND operation.

Parameters
valueThe array with which to perform the bitwise AND operation.
Returns
An array containing the result of the bitwise AND operation, which is a reference to the current T:System.Collections.BitArray object.
Exceptions
T:System.ArgumentNullExceptionvalue is null.
T:System.ArgumentExceptionvalue and the current T:System.Collections.BitArray do not have the same number of elements.

Definition at line 382 of file BitArray.cs.

◆ Clone()

object System.Collections.BitArray.Clone ( )

Creates a shallow copy of the T:System.Collections.BitArray.

Returns
A shallow copy of the T:System.Collections.BitArray.

Implements System.ICloneable.

Definition at line 532 of file BitArray.cs.

◆ CopyTo()

void System.Collections.BitArray.CopyTo ( Array  array,
int  index 
)

Copies the entire T:System.Collections.BitArray to a compatible one-dimensional T:System.Array, starting at the specified index of the target array.

Parameters
arrayThe one-dimensional T:System.Array that is the destination of the elements copied from T:System.Collections.BitArray. The T:System.Array must have zero-based indexing.
indexThe zero-based index in array at which copying begins.
Exceptions
T:System.ArgumentNullExceptionarray is null.
T:System.ArgumentOutOfRangeExceptionindex is less than zero.
T:System.ArgumentExceptionarray is multidimensional.-or- The number of elements in the source T:System.Collections.BitArray is greater than the available space from index to the end of the destination array .
T:System.InvalidCastExceptionThe type of the source T:System.Collections.BitArray cannot be cast automatically to the type of the destination array .

Implements System.Collections.ICollection.

Definition at line 481 of file BitArray.cs.

◆ Get()

bool System.Collections.BitArray.Get ( int  index)

Gets the value of the bit at a specific position in the T:System.Collections.BitArray.

Parameters
indexThe zero-based index of the value to get.
Returns
The value of the bit at position index .
Exceptions
T:System.ArgumentOutOfRangeExceptionindex is less than zero.-or- index is greater than or equal to the number of elements in the T:System.Collections.BitArray.

Definition at line 326 of file BitArray.cs.

◆ GetEnumerator()

IEnumerator System.Collections.BitArray.GetEnumerator ( )

Returns an enumerator that iterates through the T:System.Collections.BitArray.

Returns
An T:System.Collections.IEnumerator for the entire T:System.Collections.BitArray.

Implements System.Collections.IEnumerable.

Definition at line 543 of file BitArray.cs.

◆ Not()

BitArray System.Collections.BitArray.Not ( )

Inverts all the bit values in the current T:System.Collections.BitArray, so that elements set to true are changed to false, and elements set to false are changed to true.

Returns
The current instance with inverted bit values.

Definition at line 460 of file BitArray.cs.

◆ Or()

BitArray System.Collections.BitArray.Or ( BitArray  value)

Performs the bitwise OR operation between the elements of the current T:System.Collections.BitArray object and the corresponding elements in the specified array. The current T:System.Collections.BitArray object will be modified to store the result of the bitwise OR operation.

Parameters
valueThe array with which to perform the bitwise OR operation.
Returns
An array containing the result of the bitwise OR operation, which is a reference to the current T:System.Collections.BitArray object.
Exceptions
T:System.ArgumentNullExceptionvalue is null.
T:System.ArgumentExceptionvalue and the current T:System.Collections.BitArray do not have the same number of elements.

Definition at line 410 of file BitArray.cs.

◆ Set()

void System.Collections.BitArray.Set ( int  index,
bool  value 
)

Sets the bit at a specific position in the T:System.Collections.BitArray to the specified value.

Parameters
indexThe zero-based index of the bit to set.
valueThe Boolean value to assign to the bit.
Exceptions
T:System.ArgumentOutOfRangeExceptionindex is less than zero.-or- index is greater than or equal to the number of elements in the T:System.Collections.BitArray.

Definition at line 342 of file BitArray.cs.

◆ SetAll()

void System.Collections.BitArray.SetAll ( bool  value)

Sets all bits in the T:System.Collections.BitArray to the specified value.

Parameters
valueThe Boolean value to assign to all bits.

Definition at line 362 of file BitArray.cs.

◆ Xor()

BitArray System.Collections.BitArray.Xor ( BitArray  value)

Performs the bitwise exclusive OR operation between the elements of the current T:System.Collections.BitArray object against the corresponding elements in the specified array. The current T:System.Collections.BitArray object will be modified to store the result of the bitwise exclusive OR operation.

Parameters
valueThe array with which to perform the bitwise exclusive OR operation.
Returns
An array containing the result of the bitwise exclusive OR operation, which is a reference to the current T:System.Collections.BitArray object.
Exceptions
T:System.ArgumentNullExceptionvalue is null.
T:System.ArgumentExceptionvalue and the current T:System.Collections.BitArray do not have the same number of elements.

Definition at line 438 of file BitArray.cs.

Member Data Documentation

◆ Count

int System.Collections.BitArray.Count => m_length

Gets the number of elements contained in the T:System.Collections.BitArray.

Returns
The number of elements contained in the T:System.Collections.BitArray.

Definition at line 157 of file BitArray.cs.

◆ IsReadOnly

bool System.Collections.BitArray.IsReadOnly => false

Gets a value indicating whether the T:System.Collections.BitArray is read-only.

Returns
This property is always false.

Definition at line 175 of file BitArray.cs.

◆ IsSynchronized

bool System.Collections.BitArray.IsSynchronized => false

Gets a value indicating whether access to the T:System.Collections.BitArray is synchronized (thread safe).

Returns
This property is always false.

Definition at line 179 of file BitArray.cs.

Property Documentation

◆ Length

int? System.Collections.BitArray.Length
getset

Gets or sets the number of elements in the T:System.Collections.BitArray.

Returns
The number of elements in the T:System.Collections.BitArray.
Exceptions
T:System.ArgumentOutOfRangeExceptionThe property is set to a value that is less than zero.

Definition at line 120 of file BitArray.cs.

◆ SyncRoot

object System.Collections.BitArray.SyncRoot
get

Gets an object that can be used to synchronize access to the T:System.Collections.BitArray.

Returns
An object that can be used to synchronize access to the T:System.Collections.BitArray.

Definition at line 162 of file BitArray.cs.

◆ this[int index]

bool System.Collections.BitArray.this[int index]
getset

Gets or sets the value of the bit at a specific position in the T:System.Collections.BitArray.

Parameters
indexThe zero-based index of the value to get or set.
Returns
The value of the bit at position index .
Exceptions
T:System.ArgumentOutOfRangeExceptionindex is less than zero.-or- index is equal to or greater than P:System.Collections.BitArray.Count.

Definition at line 102 of file BitArray.cs.


The documentation for this class was generated from the following file: