public int CalculateMaxMemory() { var registry = new DictionarySlim <string, int>(); var max = 0; foreach (var instruction in _instructions) { instruction.Apply(registry); max = Math.Max(max, registry.OrderByDescending(x => x.Value).DefaultIfEmpty().First().Value); } return(max); }
private string WriteFrequencies(DictionarySlim <long, int> freq, int fragmentLength) { var sb = new StringBuilder(); double percent = 100.0 / freq.Select(x => x.Value).Sum(); foreach (var kv in freq.OrderByDescending(i => i.Value)) { var keyChars = new char[fragmentLength]; var key = kv.Key; for (int i = keyChars.Length - 1; i >= 0; --i) { keyChars[i] = tochar[key & 0x3]; key >>= 2; } sb.Append(keyChars); sb.Append(" "); sb.AppendLine((kv.Value * percent).ToString("F3")); } return(sb.ToString()); }