Change expected/max calculation when changing the dataset

This commit is contained in:
NunoSempere 2021-11-28 15:46:54 +00:00
parent 56bab8f861
commit 2b9ce6e142

View File

@ -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)
}
@ -201,7 +208,7 @@ export default function ComparisonView({ listOfElementsForView }) {
setSliderValue(1)
setReasoning('')
increaseNumSteps(numSteps+1)
increaseNumSteps(numSteps + 1)
if (successStatus) {
let jsObject = nicelyFormatLinks(quantitativeComparisons, listOfElements)
pushToMongo(jsObject)