public void Build(IList<int> seq, int sigma, short B = 0, ListIBuilder list_builder = null, BitmapFromBitStream bitmap_builder = null)
{
if (list_builder == null) {
list_builder = ListIBuilders.GetListIFS ();
}
if (bitmap_builder == null) {
bitmap_builder = BitmapBuilders.GetGGMN_wt (16);
}
if (B <= 0) {
B = (short)sigma;
}
this.sigma = sigma;
this.B = B;
var S = new BitStream32[sigma];
int n = seq.Count;
// Console.WriteLine ("===== building");
// bool show_more = false;
for (int i = 0; i < n; ++i) {
if (i % this.B == 0) {
for (int c = 0; c < sigma; ++c) {
if (i == 0) {
S [c] = new BitStream32 ();
}
S [c].Write (true);
}
}
var sym = seq [i];
// if (i < 128 && sym == 14) {
// Console.WriteLine ("i: {0}, sym: {1}", i, sym);
// show_more = true;
// }
S [sym].Write (false);
}
var ostream = S [0];
for (int c = 1; c < sigma; ++c) {
var istream = S [c];
for (int i = 0; i < istream.CountBits; ++i) {
ostream.Write (istream [i]);
}
}
this.X = bitmap_builder (new FakeBitmap (ostream));
// if (show_more) {
// Console.WriteLine ("=== STREAM: {0}", S [14]);
// Console.WriteLine ("=== BUILD n: {0}, X.Count: {1}, X.Count1: {2}", n, this.X.Count, this.X.Count1);
// }
this.SEQ = list_builder(seq, sigma);
}