こんにちは私はキューのベクトルの中から最小サイズのキューを見つける次のコードを持っており、最小サイズのキューはenqueue(push)
毎回intに使用されます
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)
}
今、私の別のパラダイムは、別の関数(以下に表示)でdequeue(pop)操作を実行することですが、enqueue()関数で宣言されたキューのすべてのベクトルにアクセスする必要があります。enqueue()関数で指定されたキューのループをどのように処理できますか?
void dequeue(){
//q.pop operation , access all the queues in the vector of queues
}
しますq[i].pop(int)
; エンキュー機能のすべてのキューにアクセスし、ポップ操作を行いますか?