mirror of https://github.com/ogoun/Zero.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
676 B
24 lines
676 B
using System;
|
|
using ZeroLevel.Collections;
|
|
|
|
namespace ZeroLevel.Extensions
|
|
{
|
|
internal static class BitArrayExtensions
|
|
{
|
|
// <summary>
|
|
// serialize a bitarray.
|
|
// </summary>
|
|
//<param name="bits">The bit array to convert</param>
|
|
// <returns>The bit array converted to an array of bytes.</returns>
|
|
internal static byte[] ToBytes(this FastBitArray bits)
|
|
{
|
|
if (bits == null) return null;
|
|
var numBytes = bits.Count / 8;
|
|
if (bits.Count % 8 != 0) numBytes++;
|
|
var bytes = new byte[numBytes];
|
|
bits.CopyTo(bytes, 0);
|
|
return bytes;
|
|
}
|
|
}
|
|
}
|