I have a paradigm where in a loop of queues of a vector,if a condition is true for the ith queue, increase queuesize of that ith queue by 5 . After this operation i need to search the queue sizes of all queues and enqueue in the shortest queue. i want to do something like the code given below
#include <vector>
#include <queue>
int min_index = 0;
std::vector<std::queue<int> > q
std::size_t size = q.size();
for( i=0; i<size; i++){
if(..) {// A condition is true
//increase the size of the ith queue by 5 more times
}
if(q[min_index].size() > q[i].size())
min_index = i; // Now q[min_index] is the shortest queue
}
q[min_index].push(int)
}
how to increase the queue size artifically, if a condition is true? and then search the queues and find the shortest size queue.
UPDATED
#include <vector>
#include <deque>
int min_index = 0;
std::vector<std::deque<int> > q
std::size_t size = q.size();
for( i=0; i<size; i++){
if(...) {// A condition is true
q[i].resize(q[i].size() + 5)
}
if(q[min_index].size() > q[i].size())
min_index = i; // Now q[min_index] is the shortest queue
}
q[min_index].push(int)
}