| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 84 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import React from 'react' |
||
| 2 | import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom' |
||
| 3 | import Visualizer from './components/visualizer' |
||
| 4 | |||
| 5 | import { |
||
| 6 | bubbleSort, |
||
| 7 | insertionSort, |
||
| 8 | quickSort, |
||
| 9 | shellSort |
||
| 10 | } from './components/algorithms' |
||
| 11 | |||
| 12 | import './App.css' |
||
| 13 | |||
| 14 | let amount = 100 |
||
| 15 | let randomNumbers = [...Array(amount).keys()].map(x => Math.random()) |
||
| 16 | |||
| 17 | const algorithms = [ |
||
| 18 | { |
||
| 19 | name: 'Shell sort', |
||
| 20 | path: '/shell', |
||
| 21 | algorithm: shellSort, |
||
| 22 | data: shellSort(randomNumbers), |
||
| 23 | prev: '/bubble', |
||
| 24 | next: '/quick', |
||
| 25 | speed: 10 |
||
| 26 | }, |
||
| 27 | { |
||
| 28 | name: 'Quick sort', |
||
| 29 | path: '/quick', |
||
| 30 | algorithm: quickSort, |
||
| 31 | data: quickSort(randomNumbers), |
||
| 32 | prev: '/shell', |
||
| 33 | next: '/insertion', |
||
| 34 | speed: 10 |
||
| 35 | }, |
||
| 36 | { |
||
| 37 | name: 'Insertion Sort', |
||
| 38 | path: '/insertion', |
||
| 39 | algorithm: insertionSort, |
||
| 40 | data: insertionSort(randomNumbers), |
||
| 41 | prev: '/quick', |
||
| 42 | next: '/bubble' |
||
| 43 | // speed: 0.2 |
||
| 44 | }, |
||
| 45 | { |
||
| 46 | name: 'Bubble sort', |
||
| 47 | path: '/bubble', |
||
| 48 | algorithm: bubbleSort, |
||
| 49 | data: bubbleSort(randomNumbers), |
||
| 50 | prev: '/insertion', |
||
| 51 | next: '/shell', |
||
| 52 | speed: 1 |
||
| 53 | } |
||
| 54 | ] |
||
| 55 | |||
| 56 | export default function App () { |
||
| 57 | return ( |
||
| 58 | <Router> |
||
| 59 | <Route path='/' exact render={() => <Redirect to='/shell' />} /> |
||
| 60 | |||
| 61 | {algorithms.map((item, index) => ( |
||
| 62 | <Route |
||
| 63 | key={index} |
||
| 64 | exact |
||
| 65 | path={item.path} |
||
| 66 | render={() => ( |
||
| 67 | // <Layout |
||
| 68 | // length={item.data.length} |
||
| 69 | // content={ |
||
| 70 | <Visualizer |
||
| 71 | algorithm={item.algorithm} |
||
| 72 | name={item.name} |
||
| 73 | next={item.next} |
||
| 74 | speed={item.speed} |
||
| 75 | // /> |
||
| 76 | // } |
||
| 77 | /> |
||
| 78 | )} |
||
| 79 | /> |
||
| 80 | ))} |
||
| 81 | </Router> |
||
| 82 | ) |
||
| 83 | } |
||
| 84 |