natix.CompactDS.SeqPlain.Build C# (CSharp) Method

Build() public method

public Build ( IList seq, int sigma, short B, ListIBuilder list_builder = null, BitmapFromBitStream bitmap_builder = null ) : void
seq IList
sigma int
B short
list_builder ListIBuilder
bitmap_builder BitmapFromBitStream
return void
        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);
        }

Usage Example

Ejemplo n.º 1
0
 public static SequenceBuilder GetSeqPlain(short B = 0, ListIBuilder list_builder = null, BitmapFromBitStream bitmap_builder = null, bool CopyOnUnravel = false)
 {
     return delegate (IList<int> seq, int sigma) {
         if (CopyOnUnravel) {
             var s = new SeqPlainCopyOnUnravel();
             s.Build(seq, sigma, B, list_builder, bitmap_builder);
             return s;
         } else {
             var s = new SeqPlain();
             s.Build(seq, sigma, B, list_builder, bitmap_builder);
             return s;
         }
     };
 }