@coder777
if i want the pop the element in an another function (which does not have this for loop), and i want the pop the elements of all the queues(not from 2nd to last queue) how can i do that,
for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
std::vector<std::queue<int> > q
void enqueue(){
int min_index = 1;
std::size_t size = q.size();
for( i=2; i<size; i++) //accessing loop of queues
if(q[min_index].size() > q[i].size())
min_index = i; // Now q[min_index] is the shortest queue
q[min_index].push(int)
}
void dequeue(){
//q.pop operation , access all the queues in the loop of queues
}
how can i access the loop of queues in another function, willq[i].pop(int); access all the queues in the enqueue function and does the pop operation?
@coder777
just another small doubt, you said q is a global variable, so do i need to declare again std::size_t size = q.size(); inside the dequeue() function also?