State

private enum State

State handling for ShellSort step by step sorting.

The various loops in the realAlgorithm() implementation are “opened up” to nextStep(...) implementation using state variable. Depending on the state (which loop and which part of the loop) is executed, state is changed. See comments in realAlgorithm(...) for details.

  • Sorting is executing the beginning part of second inner loop.

    Declaration

    Swift

    case inLevel2LoopStart
  • Sorting is executing the level 3 loop.

    Declaration

    Swift

    case inLevel3Loop
  • Sorting is executing second inner loop after the level 3 loop.

    Declaration

    Swift

    case inLevel2LoopEnd
  • Sorting is updating the gap variable (first level loop).

    Declaration

    Swift

    case gapUpdate