Skip to content

Commit 0ca923b

Browse files
committed
Resolved error with parameter files. Blocker currently at data structure.
1 parent 4bcfe64 commit 0ca923b

File tree

6 files changed

+56
-93
lines changed

6 files changed

+56
-93
lines changed

.idea/workspace.xml

Lines changed: 34 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
1-
// Heapsort animation
2-
//
3-
// It's worth looking at this code if you are planning to write any new
4-
// modules.
5-
//
6-
// This was the first animation done and the code is reasonably simple -
7-
// the abstractions supported match what we need for this algorithm.
8-
// For various other algorithms, the code seems much more messy - maybe
9-
// the abstractions for the data structures/rendering are not quite what
10-
// is needed or the coding is done with a sledgehammer, so to speak.
11-
//
12-
// The original version of this code was not quite right in the way it
13-
// adapted (or didn't adapt) to expansion/collapse of code blocks. This
14-
// was added later in a reasonably simple way (again, other algorithms
15-
// may use the sledgehammer style).
16-
//
17-
// One thing that could make the code here more readable is to use
18-
// meaningful strings for bookmarks rather than numbers.
19-
201
/* eslint-disable no-multi-spaces,indent,prefer-destructuring,brace-style */
21-
import GraphTracer from '../../components/DataStructures/Graph/GraphTracer';
22-
import ArrayTracer from '../../components/DataStructures/Array/Array1DTracer';
232
import {areExpanded} from './collapseChunkPlugin';
3+
import ListTracer from "../../components/DataStructures/List/ListTracer";
4+
import linkedListTracer from "../../components/DataStructures/LinkedList/LinkedListTracer";
245

6+
/*
257
const LL_BOOKMARKS = {
268
LL_default: 1,
279
LL_if_left_less_right: 2,
@@ -35,56 +17,28 @@ const LL_BOOKMARKS = {
3517
LL_pre_left: 300,
3618
LL_pre_right: 400,
3719
};
38-
39-
40-
41-
42-
43-
44-
45-
46-
47-
48-
49-
// k displayed only if first BuildHeap is expanded
50-
// Note: This is only needed in the last chunk of BuildHeap. The code
51-
// looks like it displays k throughout BuildHeap but when BuildHeap is
52-
// collapsed, only the last chunk is rendered so the other chunks don't
53-
// matter and we can avoid testing what is expanded there. Another
54-
// approach would be to use a wrapper function for assigning to k, which
55-
// checks isBuildHeapExpanded() (it doesn't generalise well for i and j
56-
// though).
57-
function isBuildHeapExpanded() {
58-
return areExpanded(['BuildHeap']);
59-
}
60-
61-
// i, j (in build) displayed only if first DownHeap is expanded
62-
// See Note in isBuildHeapExpanded()
63-
function isDownHeapkExpanded() {
64-
return areExpanded(['BuildHeap', 'DownHeapk']);
65-
}
66-
67-
import ListTracer from '../../components/DataStructures/List/ListTracer.js';
68-
20+
*/
6921
export default {
22+
7023
initVisualisers() {
7124
return {
7225
list: {
73-
instance: new ListTracer('array', null, 'List Prototype', { arrayItemMagnitudes: true }), // Label the input array as array view
26+
instance: new ListTracer('list', null, 'List Prototype', { arrayItemMagnitudes: true }), // Label the input array as array view
7427
order: 0,
7528
}
7629
};
77-
7830
},
31+
7932
run(chunker, {values}) {
8033

8134
chunker.add(
82-
1,
35+
0,
8336
(vis, list) => {
8437
vis.list.set(list, "Prototype");
8538
},
8639
[values]
8740
);
8841
}
89-
9042
};
43+
44+

src/algorithms/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,19 +308,20 @@ const allalgs = {
308308
},
309309
},
310310

311-
'LINKED_LIST_PROTOTYPE': {
311+
// When changing name, make sure this name matches with prototype name.
312+
'Linked List Prototype': {
312313
noDeploy: false,
313-
name: 'Linked List prototype',
314+
name: 'prototype (doesn\'t need to match/',
314315
category: 'Insert/Sort',
315316
explanation: Explanation.PROTOTYPE,
316-
param: <Param.PROTOTYPE_PARAM/>,
317+
param: <Param.PROTOTYPE_PARAM />,
317318
instructions: Instructions.PROTOTYPEINSTRUCTION,
318319
extraInfo: ExtraInfo.PROTOTYPE,
319320
pseudocode: {
320-
Sort: Pseudocode.PROTOTYPE,
321+
sort: Pseudocode.PROTOTYPE,
321322
},
322323
controller: {
323-
Sort: Controller.PROTOTYPE,
324+
sort: Controller.PROTOTYPE,
324325
},
325326
},
326327
};

src/algorithms/parameters/PrototypeParam.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ function PrototypeParam() {
1515
return (
1616
<>
1717
<div className="form">
18-
<ListParam
19-
name="Linked List Prototype"
18+
<ListParam
19+
name='Linked List Prototype'
2020
buttonName="Sort"
2121
mode="sort"
2222
formClassName="formLeft"
@@ -27,6 +27,9 @@ function PrototypeParam() {
2727
setMessage={setMessage}
2828
/>
2929
</div>
30+
31+
{/* render success/error message */}
32+
{message}
3033
</>
3134
);
3235
}

src/components/DataStructures/List/ListTracer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable import/no-unresolved */
2-
32
import Tracer from '../common/Tracer';
43

54
class ListTracer extends Tracer {

src/context/actions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export const GlobalActions = {
242242
// run an algorithm by executing the algorithm
243243
RUN_ALGORITHM: (state, params) => {
244244
const data = algorithms[params.name];
245+
245246
const {
246247
param,
247248
controller,

0 commit comments

Comments
 (0)