ベクトルのキューのループで、i 番目のキューの条件が true の場合、その i 番目のキューの queuesize を 5 増やすというパラダイムがあります。この操作の後、すべてのキューのキュー サイズを検索し、最短のキューにエンキューする必要があります。以下のコードのようなことをしたい
#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)
}
条件が真の場合、キューサイズを人為的に増やす方法は? 次に、キューを検索して、最小サイズのキューを見つけます。
更新しました
#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)
}