I am beginner.Let suppose I create
map<int, node*> mp;
where a node is
struct node{
node *previous;
int key; // I have no idea why there is a key variable in this node
int value;
node *next
};
So the map has int key, points to the node of a doubly linked list.
Let suppose I inserted the following elements in the order.
<key,(let corresponding node.value element be)>
<5, 1>
<10,2>
<8, 3>
So the doubly linked list looks like:
1<->2<->3
Now if I want to insert a new node in between existing nodes with node values 2,3. And so I created a new map element.
<key,(let corresponding node.value element be)>
<7, 4>
And the (newly adjusted) doubly linked list looks like:(as per my requirement)
1<->2<->4<->3
Which element will mp.erase(mp.end()); delete,and why?
I wrote a sample program in which map element <8,3> is deleted.Why does this happen?
FYI: I am working for the LRUcache code.