private void HandleStep(DsaStepContext context) { foreach (var(row, column) in GetRowsAndColumnsForStep(context)) { Context.Heights[row, column] = GetNeighboursHeightAverage(row, column, context.HalfStep) + displacer.GetNormalizedDisplacement(context.Iteration); } }
protected abstract IEnumerable <(int row, int column)> GetRowsAndColumnsForStep(DsaStepContext context);
protected override IEnumerable <(int row, int column)> GetRowsAndColumnsForStep(DsaStepContext context) { for (int row = context.HalfStep; row < Context.Length; row += context.Step) { for (int column = context.HalfStep; column < Context.Length; column += context.Step) { yield return(row, column); } } }
public void Execute(int iteration) { var context = new DsaStepContext(Context.Length, iteration); HandleStep(context); }
protected override IEnumerable <(int row, int column)> GetRowsAndColumnsForStep(DsaStepContext context) { var start = context.HalfStep; for (int row = 0; row < Context.Length; row += context.HalfStep) { for (int column = start; column < Context.Length; column += context.Step) { yield return(row, column); } start = (start + context.HalfStep) % context.Step; } }