Change expected/max calculation when changing the dataset
This commit is contained in:
parent
56bab8f861
commit
2b9ce6e142
|
@ -52,8 +52,8 @@ export default function ComparisonView({ listOfElementsForView }) {
|
|||
let initialShowComparisons = false
|
||||
let initialShowChangeDataSet = false
|
||||
let initialNumSteps = 0;
|
||||
let maxSteps = maxMergeSortSteps(listOfElementsForView.length)
|
||||
let expectedSteps = expectedNumMergeSortSteps(listOfElementsForView.length)
|
||||
let initialMaxSteps = maxMergeSortSteps(listOfElementsForView.length)
|
||||
let initialExpectedSteps = expectedNumMergeSortSteps(listOfElementsForView.length)
|
||||
|
||||
//let listOfElements = listOfElementsForView.map((element, i) => ({...element, id: i}))
|
||||
//let list = increasingList(listOfElementsForView.length) // [0,1,2,3,4]
|
||||
|
@ -77,7 +77,8 @@ export default function ComparisonView({ listOfElementsForView }) {
|
|||
let [showComparisons, changeShowComparisons] = useState(initialShowComparisons);
|
||||
let [showChangeDataSet, changeshowChangeDataSet] = useState(initialShowChangeDataSet);
|
||||
let [numSteps, increaseNumSteps] = useState(initialNumSteps);
|
||||
|
||||
let [maxSteps, changeMaxSteps] = useState(initialMaxSteps)
|
||||
let [expectedSteps, changeExpectedSteps] = useState(initialExpectedSteps)
|
||||
|
||||
let restart = (posList) => {
|
||||
setToComparePair([posList[posList.length - 2], posList[posList.length - 1]])
|
||||
|
@ -93,9 +94,15 @@ export default function ComparisonView({ listOfElementsForView }) {
|
|||
listOfElementsNew =
|
||||
listOfElementsNew.map((element, i) => ({ ...element, id: i }))
|
||||
let newPosList = increasingList(listOfElementsNew.length)
|
||||
let newListLength = listOfElementsNew.length
|
||||
|
||||
setListOfElements(listOfElementsNew)
|
||||
setPosList(increasingList(listOfElementsNew.length))
|
||||
setToComparePair([newPosList[newPosList.length - 2], newPosList[newPosList.length - 1]])
|
||||
|
||||
changeExpectedSteps(expectedNumMergeSortSteps(newListLength))
|
||||
changeMaxSteps(maxMergeSortSteps(newListLength))
|
||||
|
||||
restart(newPosList)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user