public static SequenceBuilder GetGolynskiListRL2(short t = 16, short block_size = 127, IIEncoder32 coder = null) { return delegate (IList<int> seq, int sigma) { var S = new GolynskiListRL2Seq (); //S.PermCodingBuildParams = new SuccRL2CyclicPerms_MRRR.BuildParams (coder, block_size); if (coder == null) { coder = new EliasDelta (); } S.Build (seq, sigma, t, coder, block_size); return S; }; }
/// <summary> /// build methods /// </summary> public void Build(IEnumerable<int> orderedList, int n, short b, IIEncoder32 coder = null) { this.N = n; this.B = b; this.M = 0; if (coder == null) { coder = new EliasDelta (); } this.Coder = coder; int prev = -1; var ctx = new BitStreamCtxRL (); foreach (var current in orderedList) { if (current == 0) { prev = AccStart; } this.M++; int diff = current - prev; //Console.WriteLine ("DIFF {0}, num: {1}", diff, num++); if (diff == 1) { ++ctx.run_len; } else { this.Commit (ctx); // Console.WriteLine ("%%%%%% diff: {0}, prev: {1}, curr: {2}", diff, prev, current); Coder.Encode (this.Stream, diff); } if (this.M % this.B == 0) { this.Commit (ctx); this.Samples.Add (current); this.Offsets.Add (this.Stream.CountBits); } if (current >= this.N) { this.N = current + 1; } prev = current; } this.Commit (ctx); /*for (int i = 0; i < this.Samples.Count; i++) { Console.WriteLine ("-- i: {0}, samples: {1}, offset: {2}", i, Samples[i], Offsets[i]); }*/ }
/// <summary> /// build methods /// </summary> public void Build(IEnumerable<int> orderedList, int n, short b, IIEncoder32 coder = null) { this.N = n; this.B = b; this.M = 0; if (coder == null) { coder = new EliasDelta (); } this.Coder = coder; int prev = -1; foreach (var current in orderedList) { this.Add (current, prev); prev = current; } }