I'm working on this GenerateLeafList method
// Generate the leaf list for the Huffman algorithm (used in READ AND WRITE)
//
// Note: Will cause leaks until ClearTree is implemented
void GenerateLeafList() {
// 1. Iterate through the frequency table and dynamically create a leaf node for each non-0
// frequency. Add it to the mLeafList vector.
mLeafList.clear();
for (int i = 0; i < std::size(mFrequencyTable); i++)
{
if (mFrequencyTable[i] != 0 ) //&& mFrequencyTable[i] != 256
{
//Nodes should be dynamically alocated before put in leaf list
HuffNode* newLeaf = new HuffNode(i, mFrequencyTable[i]);
mLeafList.push_back(newLeaf);
}
}
}
The error when I try to test is Exception thrown: read access violation.
_Pnext was 0x8. on the function
#if _ITERATOR_DEBUG_LEVEL == 2
_CONSTEXPR20 void _Orphan_range_unlocked(pointer _First, pointer _Last) const {
_Iterator_base12** _Pnext = &_Mypair._Myval2._Myproxy->_Myfirstiter;
while (*_Pnext) {
const auto _Pnextptr = static_cast<const_iterator&>(**_Pnext)._Ptr;
if (_Pnextptr < _First || _Last < _Pnextptr) { // skip the iterator
const auto _Temp = *_Pnext; // TRANSITION, VSO-1269037
_Pnext = &_Temp->_Mynextiter;
} else { // orphan the iterator
const auto _Temp = *_Pnext; // TRANSITION, VSO-1269037
_Temp->_Myproxy = nullptr;
*_Pnext = _Temp->_Mynextiter;
}
}
}```