Skip to content

Commit 2ac81a6

Browse files
arrumando codigo
Signed-off-by: Guilherme Deusdará <[email protected]> Co-authored-by: Isaque Alves <[email protected]>
1 parent db746ee commit 2ac81a6

File tree

2 files changed

+24
-42
lines changed

2 files changed

+24
-42
lines changed

App.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import MergeSort from './src/algorithms/MergeSort';
77
import ShellSort from './src/algorithms/ShellSort';
88

99
// 0: slowest, 500: fastest
10-
const DEFAULT_SORT_SPEED = 24.7;
11-
const MAX_SPEED = 50;
12-
const MIN_SPEED = 1;
13-
const NUMBERS_AMOUNT = 100;
10+
const DEFAULT_SORT_SPEED = 5;
11+
const MAX_SPEED = 500;
12+
const MIN_SPEED = 0;
13+
const NUMBERS_AMOUNT = 50;
1414

1515
export default class App extends React.Component {
1616
sortAlgorithm;
@@ -27,14 +27,14 @@ export default class App extends React.Component {
2727
}
2828

2929
resetTimer() {
30-
if (this.intervalId)
30+
if (this.intervalId) {
3131
clearInterval(this.intervalId);
32+
}
3233
this.intervalId = setInterval(() => {
33-
if (!this.sortAlgorithm)
34+
if (!this.sortAlgorithm) {
3435
return;
35-
while (!this.sortAlgorithm.isCompleted() && !this.sortAlgorithm.next()) {
36-
3736
}
37+
while (!this.sortAlgorithm.isCompleted() && !this.sortAlgorithm.next()) {}
3838
this.setState(() => {
3939
return {
4040
data: this.sortAlgorithm.getData(),
@@ -44,14 +44,17 @@ export default class App extends React.Component {
4444
}
4545

4646
generateRandomValues(amount) {
47-
values = [];
48-
for (var i = 0; i < amount; i++)
49-
values[i] = parseInt(Math.random() * 100);
47+
let values = [];
48+
for (var i = 0; i < amount; i++) {
49+
values[i] = parseInt(Math.random() * NUMBERS_AMOUNT + 1);
50+
}
5051
return values;
5152
}
5253

5354
setBubbleSort() {
54-
this.sortAlgorithm = new BubbleSort(this.generateRandomValues(NUMBERS_AMOUNT));
55+
this.sortAlgorithm = new BubbleSort(
56+
this.generateRandomValues(NUMBERS_AMOUNT),
57+
);
5558
this.setState(() => {
5659
return {
5760
data: this.sortAlgorithm.getData(),
@@ -60,7 +63,9 @@ export default class App extends React.Component {
6063
}
6164

6265
setQuickSort() {
63-
this.sortAlgorithm = new QuickSort(this.generateRandomValues(NUMBERS_AMOUNT));
66+
this.sortAlgorithm = new QuickSort(
67+
this.generateRandomValues(NUMBERS_AMOUNT),
68+
);
6469
this.setState(() => {
6570
return {
6671
data: this.sortAlgorithm.getData(),
@@ -69,7 +74,9 @@ export default class App extends React.Component {
6974
}
7075

7176
setMergeSort() {
72-
this.sortAlgorithm = new MergeSort(this.generateRandomValues(NUMBERS_AMOUNT));
77+
this.sortAlgorithm = new MergeSort(
78+
this.generateRandomValues(NUMBERS_AMOUNT),
79+
);
7380
this.setState(() => {
7481
return {
7582
data: this.sortAlgorithm.getData(),
@@ -78,7 +85,9 @@ export default class App extends React.Component {
7885
}
7986

8087
setShellSort() {
81-
this.sortAlgorithm = new ShellSort(this.generateRandomValues(NUMBERS_AMOUNT));
88+
this.sortAlgorithm = new ShellSort(
89+
this.generateRandomValues(NUMBERS_AMOUNT),
90+
);
8291
this.setState(() => {
8392
return {
8493
data: this.sortAlgorithm.getData(),

src/algorithms/BucketSort.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)