Background and motivation
Hello,
The System.Collection.BitArray has a constructor that accepts an array of boolean, byte or int.
As we now have ReadOnlySpan<byte>, ReadOnlySpan<bool> and ReadOnlySpan<int>, that would be great to add three new constructors to accept these span.
Currently we must do a ".ToArray" on the span.
API Proposal
namespace System.Collections;
public sealed class BitArray : ICollection, ICloneable // So, the existing one
{
public BitArray(ReadOnlySpan<byte> bytes);
public BitArray(ReadOnlySpan<bool> values);
public BitArray(ReadOnlySpan<int> values);
}
API Usage
ReadOnlySpan<int> myIntSpan = new[] { 1, 2, 3 }
var array1 = new BitArray(myIntSpan);
ReadOnlySpan<bool> myBoolSpan = new[] { true, false, true }
var array2 = new BitArray(myBoolSpan);
ReadOnlySpan<byte> myByteSpan = new[] { 5, 6, 7 }
var array3 = new BitArray(myByteSpan);
Alternative Designs
No response
Risks
No response
Background and motivation
Hello,
The System.Collection.BitArray has a constructor that accepts an array of boolean, byte or int.
As we now have
ReadOnlySpan<byte>,ReadOnlySpan<bool>andReadOnlySpan<int>, that would be great to add three new constructors to accept these span.Currently we must do a ".ToArray" on the span.
API Proposal
API Usage
Alternative Designs
No response
Risks
No response