C# Class GSF.Collections.BitArray

Provides an array of bits. Much like the native .NET implementation, however this focuses on providing a free space bit array.
Show file Open project: GridProtectionAlliance/openHistorian Class Usage Examples

Public Methods

Method Description
AreAllBitsCleared ( int index, int length ) : bool

Determines if any of the provided bits are cleared.

AreAllBitsSet ( int index, int length ) : bool

Determines if any of the provided bits are set.

BitArray ( bool initialState, int count = BitsPerElement ) : System

Initializes BitArray.

ClearAll ( ) : void

Clears all bits.

ClearBit ( int index ) : void

Sets the corresponding bit to false

ClearBits ( int index, int length ) : void

Clears a series of bits

EnsureCapacity ( int capacity ) : void

Verifies that the BitArray has the capacity to store the provided number of elements. If not, the bit array will autogrow by a factor of 2 or at least the capacity

FindClearedBit ( ) : int

Returns the index of the first bit that is cleared. -1 is returned if all bits are set.

FindSetBit ( ) : int

Returns the index of the first bit that is set. -1 is returned if all bits are set.

GetAllClearedBits ( ) : IEnumerable

Yields a list of all bits that are cleared.

GetAllSetBits ( ) : IEnumerable

Yields a list of all bits that are set.

GetBit ( int index ) : bool

Gets the status of the corresponding bit.

SetAll ( ) : void

Sets all bits.

SetBit ( int index ) : void

Sets the corresponding bit to true

SetBits ( int index, int length ) : void

Sets a series of bits

SetCapacity ( int capacity ) : void

Increases the capacity of the bit array. Decreasing capacity is currently not supported

TryClearBit ( int index ) : bool

Sets the corresponding bit to false. Returns true if the bit state was changed.

True if the bit state was changed. False if the bit was already cleared.

TrySetBit ( int index ) : bool

Sets the corresponding bit to true. Returns true if the bit state was changed.

True if the bit state was changed. False if the bit was already set.

this ( int index ) : bool

Gets/Sets individual bits in this array.

Private Methods

Method Description
GetBitUnchecked ( int index ) : bool
ThrowException ( int index ) : void
ThrowException ( int index, int length ) : void
Validate ( int index ) : void
Validate ( int index, int length ) : void

Method Details

AreAllBitsCleared() public method

Determines if any of the provided bits are cleared.
public AreAllBitsCleared ( int index, int length ) : bool
index int the starting index
length int the length of the run
return bool

AreAllBitsSet() public method

Determines if any of the provided bits are set.
public AreAllBitsSet ( int index, int length ) : bool
index int the starting index
length int the length of the run
return bool

BitArray() public method

Initializes BitArray.
public BitArray ( bool initialState, int count = BitsPerElement ) : System
initialState bool Set to true to initial will all elements set. False to have all elements cleared.
count int The number of bit positions to support
return System

ClearAll() public method

Clears all bits.
public ClearAll ( ) : void
return void

ClearBit() public method

Sets the corresponding bit to false
public ClearBit ( int index ) : void
index int
return void

ClearBits() public method

Clears a series of bits
public ClearBits ( int index, int length ) : void
index int the starting index to clear
length int the length of bits
return void

EnsureCapacity() public method

Verifies that the BitArray has the capacity to store the provided number of elements. If not, the bit array will autogrow by a factor of 2 or at least the capacity
public EnsureCapacity ( int capacity ) : void
capacity int
return void

FindClearedBit() public method

Returns the index of the first bit that is cleared. -1 is returned if all bits are set.
public FindClearedBit ( ) : int
return int

FindSetBit() public method

Returns the index of the first bit that is set. -1 is returned if all bits are set.
public FindSetBit ( ) : int
return int

GetAllClearedBits() public method

Yields a list of all bits that are cleared.
public GetAllClearedBits ( ) : IEnumerable
return IEnumerable

GetAllSetBits() public method

Yields a list of all bits that are set.
public GetAllSetBits ( ) : IEnumerable
return IEnumerable

GetBit() public method

Gets the status of the corresponding bit.
public GetBit ( int index ) : bool
index int
return bool

SetAll() public method

Sets all bits.
public SetAll ( ) : void
return void

SetBit() public method

Sets the corresponding bit to true
public SetBit ( int index ) : void
index int
return void

SetBits() public method

Sets a series of bits
public SetBits ( int index, int length ) : void
index int the starting index to clear
length int the length of bits
return void

SetCapacity() public method

Increases the capacity of the bit array. Decreasing capacity is currently not supported
public SetCapacity ( int capacity ) : void
capacity int the number of bits to support
return void

TryClearBit() public method

Sets the corresponding bit to false. Returns true if the bit state was changed.
True if the bit state was changed. False if the bit was already cleared.
public TryClearBit ( int index ) : bool
index int
return bool

TrySetBit() public method

Sets the corresponding bit to true. Returns true if the bit state was changed.
True if the bit state was changed. False if the bit was already set.
public TrySetBit ( int index ) : bool
index int
return bool

this() public method

Gets/Sets individual bits in this array.
public this ( int index ) : bool
index int the bit position to get.
return bool