When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
4 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
template <unsigned int H1, unsigned int H2, unsigned int EvictThreshold>
void BaseWordSet<H1, H2, EvictThreshold>::resizeAndInsert(size_t oldSize) {
// if resizing use this for next prime
unsigned twiceSizeNextPrime = static_cast<unsigned>(oldSize) * 2;
while (!isPrime(twiceSizeNextPrime)) {
twiceSizeNextPrime++;
}
// two new arrays
std::string *tableOneCopy = new std::string[twiceSizeNextPrime];
std::string *tableTwoCopy = new std::string[twiceSizeNextPrime];
for (size_t i{0}; i < oldSize; i++) {
if (!tableOne[i].empty()) {
this->tableOneCopy->insert(tableOne[i]);
}
}
for (size_t i{0}; i < oldSize; i++) {
if (!tableTwo[i].empty()) {
this->tableOneCopy->insert(tableTwo[i]);
}
}
delete[] tableOne;
delete[] tableTwo;
// Update member variables to point to the new arrays
m_capacity = twiceSizeNextPrime;
tableOne = tableOneCopy;
tableTwo = tableTwoCopy;
}
This is my resize function if it helps understand what I'm trying to do
@arctic notch
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
!solved