private void SetIteration(uint value) { System.Diagnostics.Debug.Assert(value > 0); if (_context.controlIteration && _context.controlRecordingIteration) { return; } if (_iteration == 1 || value < _iteration) { _iteration = 1; _enumerator = _iterations.GetEnumerator(); _enumerator.MoveNext(); _enumerator.Current.Item2.mutation = 0; } uint needed = value - _iteration; if (needed == 0) { return; } while (true) { var mutator = _enumerator.Current.Item2; uint remain = (uint)mutator.count - mutator.mutation; if (remain > needed) { mutator.mutation += needed; _iteration = value; return; } needed -= remain; _enumerator.MoveNext(); _enumerator.Current.Item2.mutation = 0; } }