void NodeController :: sortData() { /* Create an array and list Fill each with random data sort and time repeat with ordered data print results */ CTECArray<int> numbersInArray(5000); CTECList<int> numbersInList; int cPlusPlusArray[5000]; for(int spot = 0; spot < 5000; spot++) { int randomValue = rand(); numbersInArray.set(spot, randomValue); numbersInList.addToEnd(randomValue); cPlusPlusArray[spot] = randomValue; } Timer sortTimer; sortTimer.startTimer(); numbersInList.selectionSort(); sortTimer.stopTimer(); sortTimer.displayTimerInformation(); sortTimer.resetTimer(); sortTimer.startTimer(); }
void HashTable<Type> :: updateTableCapacity() { int updatedCapacity = getNextPrime(); CTECList<HashNode<Type>> * updateTable = new CTECList<HashNode<Type>> [updatedCapacity]; int oldTableCapacity = tableCapacity; tableCapacity = updatedCapacity; for(int index = 0; index < oldTableCapacity; index++) { if (tableStorage[index] != nullptr) { CTECList<HashNode<Type>> temp = tableStorage[index]; for(int innerIndex = 0; innerIndex < temp.getSize(); innerIndex++) { int updatedTablePosition = findPosition(temp.get(index)); if(updateTable[updatedTablePosition] == nullptr) { CTECList<HashTable<Type>> updatedList; updatedList.addEnd(temp.get(index)); } else { updateTable[updatedTablePosition].addEnd(temp.get(index)); } } } } }
void CTECHashTable<Type>::addToTable(HashNode<Type> currentNode) { if(this->tableSize / this->tableCapacity >= this->efficiencyPercentage) { updateTableCapacity(); } int positionToInsert = findPosition(currentNode); if(tableStorage[positionToInsert] == nullptr) { CTECList<HashNode<Type> > hashList; tableStorage[positionToInsert] = hashList; hashList.addEnd(currentNode); } else { tableStorage[positionToInsert].addEnd(currentNode); } }