Merge pull request 'Mark sorted bounds and clamp array size' (#10) from bugfix/sorting_fix into main
All checks were successful
Build & Push Frontend A / docker (push) Successful in 45s
All checks were successful
Build & Push Frontend A / docker (push) Successful in 45s
Reviewed-on: #10
This commit was merged in pull request #10.
This commit is contained in:
@@ -64,6 +64,9 @@ export class SortingService {
|
||||
changed = this.switchValuesIfCorrect(arr, i, snapshots, changed);
|
||||
}
|
||||
|
||||
arr[end].state = 'sorted';
|
||||
snapshots.push(this.createSnapshot(arr));
|
||||
|
||||
//DONE
|
||||
if (!changed) {
|
||||
break;
|
||||
@@ -71,12 +74,12 @@ export class SortingService {
|
||||
|
||||
changed = false;
|
||||
end -= 1;
|
||||
for (let i = end; i >= start; i--) {
|
||||
for (let i = end-1; i >= start; i--) {
|
||||
changed = this.switchValuesIfCorrect(arr, i, snapshots, changed);
|
||||
}
|
||||
arr[start].state = 'sorted';
|
||||
snapshots.push(this.createSnapshot(arr));
|
||||
} while (changed);
|
||||
|
||||
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import {SortData, SortSnapshot} from './sorting.models';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import {MatInput} from '@angular/material/input';
|
||||
import {UrlConstants} from '../../../constants/UrlConstants';
|
||||
import {MIN} from '@angular/forms/signals';
|
||||
@Component({
|
||||
selector: 'app-sorting',
|
||||
standalone: true,
|
||||
@@ -49,6 +50,7 @@ export class SortingComponent implements OnInit {
|
||||
|
||||
newArraySizeSet()
|
||||
{
|
||||
this.arraySize = Math.min(Math.max(this.arraySize, this.MIN_ARRAY_SIZE), this.MAX_ARRAY_SIZE);
|
||||
if (this.arraySize == this.sortArray.length)
|
||||
{
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user