I have a paradigm where a integer before gets enqueued to a queue in a vector, the loop of queues is searched and integer is enqueued to a queue which has minimum size among the queues. the following code shows the operation
1 2 3 4 5 6 7 8 9 10
#include <vector>
#include <queue>
std::vector<std::queue<int> > q
int min_index = 0;
std::size_t size = q.size();
for( i=0; 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)
next i am trying to extend my paradigm with the condition, that the integers should be enqueued to the shortest queue until the count of the shortest queue is less than or equal to count of any another queues in the loop of queues.
i want to do something like the code shown below
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <vector>
#include <queue>
std::vector<std::queue<int> > q
int min_index = 0;
std::size_t size = q.size();
for( i=0; i<size; i++){ //accessing loop of queues
if(q[min_index].size() > q[i].size())
min_index = i
//p=std::size(q.begin(),q.end(),size);
}
//while(q[min_index].size <= any other queue size in the loop leaving this shortest queue)
{
q[min_index].push(int);
}
any ideas to implement this logic, will be grateful!!