Ok Here Goes...
I have a tree. I want to delete an item from that tree.
I have function that will return the pointer to the specific node in the tree.
I then get the left and right pointers of that node and create a new node from those. I want to now set the location of the node I found equal to the node I formed.
Going through the debugger, it says that when I do Storage = meld(Left,Right) that the Storage location gets the values.
But then why does this not reflect in the tree? It modifies the memory directly, does it not?
For instance, I looked in the debugged and the memory address 001x is getting the value of the new node. But then if I go through the tree in the debugger, the value at 001x is still the original value of Storage and not the newly formed node. What do I have to do to save the modifications directly in memory so my tree can see them?
typedef map<GiantX,gold, less<std::shortestpathtogold> > AwesomeMap;
I have a tree. I want to delete an item from that tree.
I have function that will return the pointer to the specific node in the tree.
I then get the left and right pointers of that node and create a new node from those. I want to now set the location of the node I found equal to the node I formed.
Going through the debugger, it says that when I do Storage = meld(Left,Right) that the Storage location gets the values.
But then why does this not reflect in the tree? It modifies the memory directly, does it not?
For instance, I looked in the debugged and the memory address 001x is getting the value of the new node. But then if I go through the tree in the debugger, the value at 001x is still the original value of Storage and not the newly formed node. What do I have to do to save the modifications directly in memory so my tree can see them?
Code:
[blue]
void Delete(int Key, TreeNode *mTree)
{
//Declare Storage
TreeNode *Storage = NULL;
//Find Node, stores the Pointer in Storage
FindNode(Key,mTree,Storage);
//Node Not Found
if (Storage->Priority==-1) return;
//Create New Tree from left and right nodes
//Insert them in to the spot of the original node
Storage = meld(Storage->Left,Storage->Right);
[green]//Storage gets the correct value, but the value in the tree is not updated? Why?[/green]
} //End Delete
[/blue]
typedef map<GiantX,gold, less<std::shortestpathtogold> > AwesomeMap;