S
sg71.cherub
HI all,
I use <queue> of STL. Before pushing an element into the queue, how to
check whether the queue has contained the element? i.e. I want the
queue has no duplicated elements. Is ther Contains() function?
e.g.
#include <queue>
int main(void)
{
queue<int> q;
q.push(1);
q.push(2);
// q.push(1); // since q now contains "1", q should not push "1"
again.
// something like
// if (!q.Contains(1))
// {
// q.push(1);
// }
return 0;
}
many thanks indeed!
I use <queue> of STL. Before pushing an element into the queue, how to
check whether the queue has contained the element? i.e. I want the
queue has no duplicated elements. Is ther Contains() function?
e.g.
#include <queue>
int main(void)
{
queue<int> q;
q.push(1);
q.push(2);
// q.push(1); // since q now contains "1", q should not push "1"
again.
// something like
// if (!q.Contains(1))
// {
// q.push(1);
// }
return 0;
}
many thanks indeed!