apply method

Cube apply(
  1. Cube cube, {
  2. int n = 1,
  3. void onProgress(
    1. Cube cube,
    2. Move move,
    3. int step,
    4. int total,
    )?,
})

Aplies n times the Algorithm to cube.

Implementation

Cube apply(
  Cube cube, {
  int n = 1,
  void Function(Cube cube, Move move, int step, int total)? onProgress,
}) {
  for (var i = 0, c = 1; i < n; i++) {
    for (var k = 0; k < length; k++, c++) {
      final move = this[k];
      cube = cube.move(move);
      onProgress?.call(cube, move, c, length * n);
    }
  }

  return cube;
}