public static RLEBitset Deserialize(Stream stream)
{
RLEBitset bitset = new RLEBitset();
//We don't care about the encoding, but we have to specify something to be able to set the stream as leave open.
using (BinaryReader reader = new BinaryReader(stream, Encoding.Default, true))
{
bitset.length = reader.ReadInt32();
while (stream.Position < stream.Length - 1)
{
Run currRun = new Run();
currRun.StartIndex = reader.ReadInt32();
currRun.EndIndex = reader.ReadInt32();
bitset.runArray.Add(currRun);
}
}
return bitset;
}