Table of Contents

Struct UnsafeBitSet

Namespace
Misaki.HighPerformance.LowLevel.Collections
Assembly
Misaki.HighPerformance.LowLevel.dll
public struct UnsafeBitSet : IDisposable, IEquatable<UnsafeBitSet>
Implements
Inherited Members

Constructors

UnsafeBitSet()

Initializes a new instance of UnsafeBitSet with a default size of 1 and a persistent allocation handle.

public UnsafeBitSet()

UnsafeBitSet(int, AllocationHandle, AllocationOption)

Initializes a new instance of the UnsafeBitSet class.

public UnsafeBitSet(int minimalLength, AllocationHandle handle, AllocationOption option = AllocationOption.None)

Parameters

minimalLength int

The minimal length in bits.

handle AllocationHandle

The allocation handle.

option AllocationOption

The allocation option.

UnsafeBitSet(Span<uint>, AllocationHandle)

Initializes a new instance of the UnsafeBitSet class.

public UnsafeBitSet(Span<uint> bits, AllocationHandle handle)

Parameters

bits Span<uint>

The bits to initialize the bitset with. The length of the bitset will be determined by the length of this span.

handle AllocationHandle

The allocation handle.

Properties

Count

Gets the total number of bits represented by the current instance.

public readonly int Count { get; }

Property Value

int

HighestBit

The highest bit set.

public readonly int HighestBit { get; }

Property Value

int

HighestIndex

The highest uint index in use inside the Misaki.HighPerformance.LowLevel.Collections.UnsafeBitSet._bits-array.

public readonly int HighestIndex { get; }

Property Value

int

IsCreated

public readonly bool IsCreated { get; }

Property Value

bool

Methods

ANDC(UnsafeBitSet)

Performs a bitwise AND NOT operation between the current bit set and the specified bit set, updating the current bit set in place.

public void ANDC(UnsafeBitSet other)

Parameters

other UnsafeBitSet

The bit set whose bits will be inverted and ANDed with the current bit set. Must have the same length as the current bit set.

Exceptions

ArgumentException

Thrown when the specified bit set does not have the same length as the current bit set.

All(UnsafeBitSet)

Checks if all bits from this instance match those of the other instance.

public readonly bool All(UnsafeBitSet other)

Parameters

other UnsafeBitSet

The other UnsafeBitSet.

Returns

bool

True if they match, false if not.

And(UnsafeBitSet)

Performs a bitwise AND operation between the current bit set and the specified bit set, updating the current bit set in place.

public void And(UnsafeBitSet other)

Parameters

other UnsafeBitSet

The bit set to combine with the current bit set using a bitwise AND operation. Must have the same length as the current bit set.

Exceptions

ArgumentException

Thrown when other does not have the same length as the current bit set.

Any(UnsafeBitSet)

Checks if any bits from this instance match those of the other instance.

public readonly bool Any(UnsafeBitSet other)

Parameters

other UnsafeBitSet

The other UnsafeBitSet.

Returns

bool

True if they match, false if not.

AsSpan()

Creates a Span<T> to access the Misaki.HighPerformance.LowLevel.Collections.UnsafeBitSet._bits.

public readonly Span<uint> AsSpan()

Returns

Span<uint>

The Span<T>.

AsSpan(Span<uint>, bool)

Copies the bits into a Span<T>.

public readonly Span<uint> AsSpan(Span<uint> span, bool zero = true)

Parameters

span Span<uint>

The Span<T> to copy into.

zero bool

If true, it will zero the unused space from the span.

Returns

Span<uint>

The Span<T>.

ClearAll()

Clears all set bits.

public void ClearAll()

ClearBit(int)

Clears the bit at the given index.

public void ClearBit(int index)

Parameters

index int

The index.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Equals(UnsafeBitSet)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(UnsafeBitSet other)

Parameters

other UnsafeBitSet

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Exclusive(UnsafeBitSet)

Checks if exactly all bits from this instance match those of the other instance.

public readonly bool Exclusive(UnsafeBitSet other)

Parameters

other UnsafeBitSet

The other UnsafeBitSet.

Returns

bool

True if they match, false if not.

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetIterator(int)

[UnscopedRef]
public UnsafeBitSet.Iterator GetIterator(int start = 0)

Parameters

start int

Returns

UnsafeBitSet.Iterator

IsSet(int)

Checks whether a bit is set at the index.

public readonly bool IsSet(int index)

Parameters

index int

The index.

Returns

bool

True if it is, otherwise false

Nand(UnsafeBitSet)

Performs a bitwise NAND operation between the current bit set and the specified bit set, updating the current bit set in place.

public void Nand(UnsafeBitSet other)

Parameters

other UnsafeBitSet

The bit set to combine with the current bit set using the NAND operation. Must have the same length as the current bit set.

Exceptions

ArgumentException

Thrown if other does not have the same length as the current bit set.

NextSetBit(int)

Finds the next set bit at or after startIndex, or -1 if none.

public readonly int NextSetBit(int startIndex)

Parameters

startIndex int

Returns

int

None(UnsafeBitSet)

Checks if none bits from this instance match those of the other instance.

public readonly bool None(UnsafeBitSet other)

Parameters

other UnsafeBitSet

The other UnsafeBitSet.

Returns

bool

True if none match, false if not.

Not()

Inverts all bits in the current vector, replacing each bit with its logical complement.

public void Not()

Or(UnsafeBitSet)

Performs a bitwise OR operation between the current bit set and the specified bit set, updating the current set in place.

public void Or(UnsafeBitSet other)

Parameters

other UnsafeBitSet

The bit set to combine with the current set using a bitwise OR operation. Must have the same length as the current bit set.

Exceptions

ArgumentException

Thrown if other does not have the same length as the current bit set.

RequiredLength(int)

Determines the required length of an UnsafeBitSet to hold the passed ID or bit.

public static int RequiredLength(int id)

Parameters

id int

The ID or bit.

Returns

int

A size of required uints for the bitset.

Resize(int, AllocationOption)

public void Resize(int minimalLength, AllocationOption option = AllocationOption.None)

Parameters

minimalLength int
option AllocationOption

SetAll()

Sets all bits.

public void SetAll()

SetBit(int)

Sets a bit at the given index. Resizes its internal array if necessary.

public void SetBit(int index)

Parameters

index int

The index.

ToString()

Returns the fully qualified type name of this instance.

public override readonly string ToString()

Returns

string

The fully qualified type name.

Xor(UnsafeBitSet)

Performs a bitwise exclusive OR (XOR) operation between the current bit set and the specified bit set.

public void Xor(UnsafeBitSet other)

Parameters

other UnsafeBitSet

The bit set to XOR with the current instance. Must have the same length as the current bit set.

Exceptions

ArgumentException

Thrown if other does not have the same length as the current bit set.

Operators

operator ==(UnsafeBitSet, UnsafeBitSet)

public static bool operator ==(UnsafeBitSet left, UnsafeBitSet right)

Parameters

left UnsafeBitSet
right UnsafeBitSet

Returns

bool

operator !=(UnsafeBitSet, UnsafeBitSet)

public static bool operator !=(UnsafeBitSet left, UnsafeBitSet right)

Parameters

left UnsafeBitSet
right UnsafeBitSet

Returns

bool