void SaveNode(BinaryWriter Output, WT_Node node)
{
var asInner = node as WT_Inner;
if (asInner != null) {
// isInner?
Output.Write (true);
GenericIO<Bitmap>.Save (Output, asInner.B);
// since it uses pointers the extra-space by booleans is a better reflect of the
// memory usage than a compact representation of the node
if (asInner.Left == null) {
Output.Write (false);
} else {
Output.Write (true);
SaveNode (Output, asInner.Left);
}
if (asInner.Right == null) {
Output.Write (false);
} else {
Output.Write (true);
SaveNode (Output, asInner.Right);
}
} else {
Output.Write (false);
var asLeaf = node as WT_Leaf;
// Output.Write ((int)asLeaf.Count);
Output.Write ((int)asLeaf.Symbol);
}
}