BitsetsNET.RoaringArray.Serialize C# (CSharp) Method

Serialize() public method

Serialize the roaring array into a binary format.
public Serialize ( BinaryWriter writer ) : void
writer BinaryWriter The writer to write the serialization to.
return void
        public void Serialize(BinaryWriter writer)
        {
            writer.Write(Size);

            for(int i = 0; i < Size; i++)
            {
                writer.Write(keys[i]);
                values[i].Serialize(writer);
            }
        }

Usage Example

Example #1
0
 /// <summary>
 /// Write a binary serialization of this roaring bitset.
 /// </summary>
 /// <param name="stream">The stream to write to.</param>
 public void Serialize(Stream stream)
 {
     //We don't care about the encoding, but we have to specify something to be able to set the stream as leave open.
     using (BinaryWriter writer = new BinaryWriter(stream, Encoding.Default, true))
     {
         containers.Serialize(writer);
     }
 }