Skip to content

Commit 7b9d063

Browse files
authored
Merge pull request #15 from csvistool/dropsort
DropSort
2 parents 0dcff4f + 7de96da commit 7b9d063

37 files changed

Lines changed: 647 additions & 200 deletions

src/AlgoList.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const algoMap = {
3434
LSDRadix: ['LSD Radix Sort', algos.LSDRadix, true],
3535
HeapSort: ['HeapSort', algos.HeapSort, true],
3636
FredSort: ['FredSort', algos.FredSort, false],
37+
DropSort: ['DropSort', algos.DropSort, false],
3738
SleepSort: ['SleepSort', algos.SleepSort, false],
3839
MiracleSort: ['MiracleSort', algos.MiracleSort, false],
3940
BruteForce: ['Brute Force', algos.BruteForce, true],
@@ -101,6 +102,8 @@ export const algoList = [
101102
'Dynamic Programming',
102103
'LCS',
103104
'Floyd',
105+
'DropSort',
106+
'FredSort',
104107
];
105108

106109
export const relatedSearches = {

src/App.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ const App = () => {
3737
return (
3838
<Router basename={process.env.PUBLIC_URL + '/'}>
3939
<Routes>
40-
<Route path="/about" element={<AboutScreen theme={theme} toggleTheme={toggleTheme} />} />
41-
<Route path="/:algo" element={<AlgoScreen theme={theme} toggleTheme={toggleTheme} />} />
40+
<Route
41+
path="/about"
42+
element={<AboutScreen theme={theme} toggleTheme={toggleTheme} />}
43+
/>
44+
<Route
45+
path="/:algo"
46+
element={<AlgoScreen theme={theme} toggleTheme={toggleTheme} />}
47+
/>
4248
<Route path="*" element={<HomeScreen theme={theme} toggleTheme={toggleTheme} />} />
4349
</Routes>
4450
</Router>

src/algo/AVL.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,22 @@ export default class AVL extends Algorithm {
131131
}
132132

133133
setURLData(searchParams) {
134-
if (searchParams.has("predSucc")) {
135-
const selection = searchParams.get("predSucc");
136-
if (selection === "pred") {
137-
this.predSucc = 'pred'
134+
if (searchParams.has('predSucc')) {
135+
const selection = searchParams.get('predSucc');
136+
if (selection === 'pred') {
137+
this.predSucc = 'pred';
138138
this.predButton.checked = true;
139-
} else if (selection === "succ") {
140-
this.predSucc = 'succ'
139+
} else if (selection === 'succ') {
140+
this.predSucc = 'succ';
141141
this.succButton.checked = true;
142142
}
143143
}
144144

145-
if (searchParams.has("data")) {
146-
const dataList = searchParams.get("data").split(",").filter(item => item.trim() !== "");
145+
if (searchParams.has('data')) {
146+
const dataList = searchParams
147+
.get('data')
148+
.split(',')
149+
.filter(item => item.trim() !== '');
147150
dataList.forEach(dataEntry => {
148151
this.implementAction(this.add.bind(this), parseInt(dataEntry), true);
149152
this.animationManager.skipForward();

src/algo/BST.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,24 +167,27 @@ export default class BST extends Algorithm {
167167
}
168168

169169
setURLData(searchParams) {
170-
if (searchParams.has("predSucc")) {
171-
const selection = searchParams.get("predSucc");
172-
if (selection === "pred") {
173-
this.predSucc = 'pred'
170+
if (searchParams.has('predSucc')) {
171+
const selection = searchParams.get('predSucc');
172+
if (selection === 'pred') {
173+
this.predSucc = 'pred';
174174
this.predButton.checked = true;
175-
} else if (selection === "succ") {
176-
this.predSucc = 'succ'
175+
} else if (selection === 'succ') {
176+
this.predSucc = 'succ';
177177
this.succButton.checked = true;
178178
}
179179
}
180180

181-
if (searchParams.has("data")) {
182-
const dataList = searchParams.get("data").split(",").filter(item => item.trim() !== "");
181+
if (searchParams.has('data')) {
182+
const dataList = searchParams
183+
.get('data')
184+
.split(',')
185+
.filter(item => item.trim() !== '');
183186
dataList.forEach(dataEntry => {
184187
this.implementAction(this.add.bind(this), parseInt(dataEntry), true);
185188
this.animationManager.skipForward();
186189
this.animationManager.clearHistory();
187-
});
190+
});
188191
}
189192
}
190193

src/algo/BTree.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -217,32 +217,32 @@ export default class BTree extends Algorithm {
217217
}
218218

219219
setURLData(searchParams) {
220-
if (searchParams.has("promote")) {
221-
const selection = searchParams.get("promote");
222-
if (selection === "second") {
223-
this.split_index = 1
220+
if (searchParams.has('promote')) {
221+
const selection = searchParams.get('promote');
222+
if (selection === 'second') {
223+
this.split_index = 1;
224224
this.splitSecondSelect.checked = true;
225225
this.splitThirdSelect.checked = false;
226-
} else if (selection === "third") {
227-
this.split_index = 2
226+
} else if (selection === 'third') {
227+
this.split_index = 2;
228228
this.splitSecondSelect.checked = false;
229-
this.splitThirdSelect.checked = true
229+
this.splitThirdSelect.checked = true;
230230
}
231231
}
232232

233-
if (searchParams.has("predSucc")) {
234-
const selection = searchParams.get("predSucc");
235-
if (selection === "pred") {
236-
this.predSucc = 'pred'
233+
if (searchParams.has('predSucc')) {
234+
const selection = searchParams.get('predSucc');
235+
if (selection === 'pred') {
236+
this.predSucc = 'pred';
237237
this.predButton.checked = true;
238-
} else if (selection === "succ") {
239-
this.predSucc = 'succ'
238+
} else if (selection === 'succ') {
239+
this.predSucc = 'succ';
240240
this.succButton.checked = true;
241241
}
242242
}
243243

244-
if (searchParams.has("data")) {
245-
const data = searchParams.get("data");
244+
if (searchParams.has('data')) {
245+
const data = searchParams.get('data');
246246
this.buildTreeField.value = data;
247247
this.buildTreeCallback();
248248
}

src/algo/BoyerMoore.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ export default class BoyerMoore extends Algorithm {
140140
}
141141

142142
setURLData(searchParams) {
143+
this.textField.value = searchParams.get('text');
144+
this.patternField.value = searchParams.get('pattern');
145+
this.findCallback();
143146
if (searchParams.has("galil")) {
144147
const enabled = searchParams.get("galil");
145148
if (enabled === "1") {
@@ -220,7 +223,8 @@ export default class BoyerMoore extends Algorithm {
220223

221224
exampleCallback() {
222225
const selection = this.exampleDropdown.value;
223-
this.exampleDropdown.options[0].text = this.exampleDropdown.options[this.exampleDropdown.selectedIndex].text;
226+
this.exampleDropdown.options[0].text =
227+
this.exampleDropdown.options[this.exampleDropdown.selectedIndex].text;
224228
if (!selection) {
225229
return;
226230
}

src/algo/BruteForce.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ export default class BruteForce extends Algorithm {
116116
}
117117

118118
setURLData(searchParams) {
119-
this.textField.value = searchParams.get("text")
120-
this.patternField.value = searchParams.get("pattern")
119+
this.textField.value = searchParams.get('text');
120+
this.patternField.value = searchParams.get('pattern');
121121
this.findCallback();
122122
}
123123

@@ -159,7 +159,8 @@ export default class BruteForce extends Algorithm {
159159

160160
exampleCallback() {
161161
const selection = this.exampleDropdown.value;
162-
this.exampleDropdown.options[0].text = this.exampleDropdown.options[this.exampleDropdown.selectedIndex].text;
162+
this.exampleDropdown.options[0].text =
163+
this.exampleDropdown.options[this.exampleDropdown.selectedIndex].text;
163164
if (!selection) {
164165
return;
165166
}

src/algo/BubbleSort.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ export default class BubbleSort extends Algorithm {
190190

191191
exampleCallback() {
192192
const selection = this.exampleDropdown.value;
193-
this.exampleDropdown.options[0].text = this.exampleDropdown.options[this.exampleDropdown.selectedIndex].text;
193+
this.exampleDropdown.options[0].text =
194+
this.exampleDropdown.options[this.exampleDropdown.selectedIndex].text;
194195
if (!selection) {
195196
return;
196197
}

src/algo/CocktailSort.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ export default class CocktailSort extends Algorithm {
196196

197197
exampleCallback() {
198198
const selection = this.exampleDropdown.value;
199-
this.exampleDropdown.options[0].text = this.exampleDropdown.options[this.exampleDropdown.selectedIndex].text;
199+
this.exampleDropdown.options[0].text =
200+
this.exampleDropdown.options[this.exampleDropdown.selectedIndex].text;
200201
if (!selection) {
201202
return;
202203
}

0 commit comments

Comments
 (0)