Skip to content

Commit 50c6642

Browse files
committed
ASP-95 CLEAN: clean up AVLTreeParam file, and fix test file undef error
1 parent ad7e47a commit 50c6642

File tree

2 files changed

+8
-129
lines changed

2 files changed

+8
-129
lines changed

src/algorithms/controllers/AVLTree.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* @since 10/10/2024
1414
*/
1515

16+
/* eslint-disable no-undef */
17+
1618
import AVLTreeInsertion from './AVLTreeInsertion';
1719

1820
// Simple stub for the chunker

src/algorithms/parameters/AVLTreeParam.js

Lines changed: 6 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,9 @@
1-
// import React, { useState, useContext, useEffect } from 'react';
2-
// import { GlobalContext } from '../../context/GlobalState';
3-
// import { GlobalActions } from '../../context/actions';
4-
// import ListParam from './helpers/ListParam';
5-
// import SingleValueParam from './helpers/SingleValueParam';
6-
// import '../../styles/Param.scss';
7-
// import {
8-
// singleNumberValidCheck,
9-
// genUniqueRandNumList,
10-
// successParamMsg,
11-
// errorParamMsg,
12-
// } from './helpers/ParamHelper';
13-
14-
// // import useParam from '../../context/useParam';
15-
16-
// const ALGORITHM_NAME = 'AVL Trees';
17-
// const INSERTION = 'Insertion';
18-
// const SEARCH = 'Search';
19-
20-
// // DEFAULT input - enough for a tree with a few levels
21-
// // Should be the same as in REFRESH_FUNCTION
22-
// const DEFAULT_NODES = genUniqueRandNumList(12, 1, 100);
23-
// const DEFAULT_TARGET = '2';
24-
25-
// const INSERTION_EXAMPLE = 'Please follow the example provided: 1,2,3,4. Values should also be unique.';
26-
// const SEARCH_EXAMPLE = 'Please follow the example provided: 16.';
27-
// const NO_TREE_ERROR = 'Please build a tree before running search.';
28-
29-
// function AVLTreeParam() {
30-
// const { algorithm, dispatch } = useContext(GlobalContext);
31-
// const [message, setMessage] = useState(null);
32-
// const [nodes, setNodes] = useState(DEFAULT_NODES);
33-
34-
35-
// const handleInsertion = (e) => {
36-
// e.preventDefault();
37-
// const list = e.target[0].value;
38-
39-
// if (validateListInput(list)) {
40-
// let nodes = list.split(',').map(Number);
41-
// // run search animation
42-
// dispatch(GlobalActions.RUN_ALGORITHM, {
43-
// name: 'AVLTree',
44-
// mode: 'insertion',
45-
// nodes,
46-
// });
47-
// setMessage(successParamMsg(ALGORITHM_NAME));
48-
// } else {
49-
// setMessage(errorParamMsg(ALGORITHM_NAME, INSERTION_EXAMPLE));
50-
// }
51-
// };
52-
// const handleSearch = (e) => {
53-
// e.preventDefault();
54-
// const inputValue = e.target[0].value;
55-
56-
// if (singleNumberValidCheck(inputValue)) {
57-
// const target = parseInt(inputValue, 10);
58-
59-
// if (
60-
// Object.prototype.hasOwnProperty.call(algorithm, 'visualisers')
61-
// && !algorithm.visualisers.tree.instance.isEmpty()
62-
// ) {
63-
// const visualiser = algorithm.chunker.visualisers;
64-
// dispatch(GlobalActions.RUN_ALGORITHM, {
65-
// name: 'AVLTree',
66-
// mode: 'search',
67-
// visualiser,
68-
// target,
69-
// });
70-
// setMessage(successParamMsg(ALGORITHM_NAME));
71-
// } else {
72-
// setMessage(errorParamMsg(ALGORITHM_NAME, NO_TREE_ERROR));
73-
// }
74-
// }
75-
// else {
76-
// setMessage(errorParamMsg(ALGORITHM_NAME, SEARCH_EXAMPLE));
77-
// }
78-
// };
79-
80-
// return (
81-
// <>
82-
// <div className="form">
83-
// {/* Insert input */}
84-
// <ListParam
85-
// name="AVLTree"
86-
// buttonName="Insert"
87-
// mode="insertion"
88-
// formClassName="formLeft"
89-
// DEFAULT_VAL={nodes}
90-
// handleSubmit={handleInsertion}
91-
// SET_VAL={setNodes}
92-
// REFRESH_FUNCTION={(() => genUniqueRandNumList(12, 1, 100))}
93-
// ALGORITHM_NAME={INSERTION}
94-
// EXAMPLE={INSERTION_EXAMPLE}
95-
// setMessage={setMessage}
96-
// />
97-
98-
// {/* Search input */}
99-
// {<SingleValueParam
100-
// name="AVLTree"
101-
// buttonName="Search"
102-
// mode="search"
103-
// formClassName="formRight"
104-
// handleSubmit={handleSearch}
105-
// DEFAULT_VAL={DEFAULT_TARGET}
106-
// ALGORITHM_NAME={SEARCH}
107-
// EXAMPLE={SEARCH_EXAMPLE}
108-
// setMessage={setMessage}
109-
// />}
110-
// </div>
111-
// {/* render success/error message */}
112-
// {message}
113-
// </>
114-
// );
115-
// }
116-
117-
// export default AVLTreeParam;
118-
119-
// function validateListInput(input) {
120-
// const inputArr = input.split(',');
121-
// const inputSet = new Set(inputArr);
122-
// return (
123-
// inputArr.length === inputSet.size
124-
// && inputArr.every((num) => singleNumberValidCheck(num))
125-
// );
126-
// }
1+
/**
2+
* AVL Tree Param Component
3+
* Including the bottom web buttons to control the animation
4+
*
5+
* Derived from the BSTParam.js file
6+
*/
1277

1288
/* eslint-disable no-prototype-builtins */
1299
/* eslint-disable max-len */
@@ -147,8 +27,6 @@ import {
14727
shuffleArray,
14828
} from './helpers/ParamHelper';
14929

150-
// import useParam from '../../context/useParam';
151-
15230
const DEFAULT_NODES = genRandNumList(10, 1, 100);
15331
const DEFAULT_TARGET = '2';
15432
const INSERTION = 'insertion';
@@ -169,7 +47,6 @@ const BlueRadio = withStyles({
16947
},
17048
},
17149
checked: {},
172-
// eslint-disable-next-line react/jsx-props-no-spreading
17350
})((props) => <Radio {...props} />);
17451

17552
function AVLTreeParam() {

0 commit comments

Comments
 (0)