Hello I'm having trouble with my unordered_map insert. My insert takes a Comparable, which is a template, and a BinomialNode* and inserts the Comparable as the key and the node as the value. When I inserted the keys and search for them, it's there in my map. My problem lies when I try to use the BinaryNode* from the map. When I output the address of the node to see if it's there, it returns 0x0, which I presume to be a nullptr. I'm stumped and can't figure out what I did wrong.
The insert function has my map insert and my contains function is trying to find the value and key if found.
ifstream myFile;
myFile.open(createQueue);
if(myFile.is_open()){
string fileLine;
// Reads the file
while(getline(myFile, fileLine)){
// Converts the string into a number
int number;
stringstream convert(fileLine);
convert >> number;
// Inserts the number into the tree
myTree.insert(number);
}
cout << "Success inserting " << numOfElement << " elements into the queue. The minimum element is " << myTree.findMin() << endl;
myTree.print();
}
else{
cout << "No file exist \n";
}
myFile.close();
Placing cout << oneItem.theTrees.at(0) << endl; inside my insert function reveals 0x0 only.
I'm having problem with my deleteItem function. It's suppose to delete any node from the queue. I get the Node from map, percolate it up, set it as min and delete that node. My problem seems to be that curr->parent is always nullptr. I'm not sure how to set the parent* as a node like how I set curr as the element node.