Struct FastBitSet32
A high-performance, stack-allocated structure wrapping a 32-bit unsigned integer (uint) to act as a set of boolean flags (bits). Provides fast indexing and highly optimized iteration over only the set bits using hardware intrinsics (BitOperations).
Namespace: Evergine.Common.Collections
Assembly: Evergine.Common.dll
Syntax
public struct FastBitSet32
Constructors
FastBitSet32(uint)
Initializes a new instance of the FastBitSet32 struct with an optional initial value.
Declaration
public FastBitSet32(uint initialValue = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | initialValue | The initial 32-bit integer mask. |
Properties
this[int]
Indexer allowing access and manipulation of individual bits by their position (0-31). Usage: bitset[9] = true; or bool isSet = bitset[5];.
Declaration
public bool this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The bit position (0 to 31). |
Property Value
| Type | Description |
|---|---|
| bool | True if the bit at the specified index is set; otherwise, false. |
Value
Gets the raw 32-bit integer value representing the set.
Declaration
public uint Value { get; }
Property Value
| Type | Description |
|---|---|
| uint |
Methods
Clear(int)
Clears the bit at the specified index to 0 (false).
Declaration
public void Clear(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the bit to clear (0-31). |
Equals(FastBitSet32)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(FastBitSet32 other)
Parameters
| Type | Name | Description |
|---|---|---|
| FastBitSet32 | other | An object to compare with this object. |
Returns
| Type | Description |
|---|---|
| bool | true if the current object is equal to the |
Equals(object)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool | true if |
Overrides
GetEnumerator()
Implements IEnumerable to allow foreach loops. This method returns an optimized enumerator that only yields the indices of set bits.
Declaration
public FastBitSet32.BitEnumerator GetEnumerator()
Returns
| Type | Description |
|---|---|
| FastBitSet32.BitEnumerator | The FastBitSet32.BitEnumerator for iterating over the set bit indices. |
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
Reset()
Resets all bits to 0.
Declaration
public void Reset()
Set(int)
Sets the bit at the specified index to 1 (true).
Declaration
public void Set(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the bit to set (0-31). |
ToString()
Returns the fully qualified type name of this instance.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The fully qualified type name. |
Overrides
Operators
operator |(FastBitSet32, FastBitSet32)
Declaration
public static FastBitSet32 operator |(FastBitSet32 left, FastBitSet32 right)
Parameters
| Type | Name | Description |
|---|---|---|
| FastBitSet32 | left | |
| FastBitSet32 | right |
Returns
| Type | Description |
|---|---|
| FastBitSet32 |
operator ==(FastBitSet32, FastBitSet32)
Declaration
public static bool operator ==(FastBitSet32 left, FastBitSet32 right)
Parameters
| Type | Name | Description |
|---|---|---|
| FastBitSet32 | left | |
| FastBitSet32 | right |
Returns
| Type | Description |
|---|---|
| bool |
operator !=(FastBitSet32, FastBitSet32)
Declaration
public static bool operator !=(FastBitSet32 left, FastBitSet32 right)
Parameters
| Type | Name | Description |
|---|---|---|
| FastBitSet32 | left | |
| FastBitSet32 | right |
Returns
| Type | Description |
|---|---|
| bool |