-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Hello!
I was working on a PR myself for this, but I have been stumped since byte[] and BitArray do not implement the IComparable interface.
You know your library much better than I do - do you have any advice how an implementation for this can be done?
My thoughts are to:
- Create some internal 'wrapper' type for
byte[] - Autmatically cast the
byte[]to the wrapper type - Keep the wrapper type 'hidden' from the user (developer) in an internal class / struct
What do you think? Any advice? Im struggling with the wrapper type being convertible to your IBaseType in the code
Can you point me in the right direction with solving this?
public class BitArrayComparable : IComparable<byte[]>
{
private readonly byte[] _bitArray;
public BitArrayComparable(byte[] bitArray)
{
this._bitArray = bitArray;
}
/// <inheritdoc />
public int CompareTo(byte[]? other)
{
var len = Math.Min(this._bitArray.Length, other.Length);
for (var i = 0; i < len; i++)
{
var c = this._bitArray[i]
.CompareTo(other[i]);
if (c != 0)
{
return c;
}
}
return other.Length.CompareTo(other.Length);
}
} I had something like this, but its not convertible to IBaseType
Thanks
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels