473,657 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Removing all elements from STL queue

I am using an STL queue ( on top of a vector ).

queue < BroadcastBuffer *, vector <BroadcastBuffe r*> > queue;

Is there anyway of flushing the queue - clear() is not available.

Sep 29 '05 #1
1 8056

"Tommo" <ma**********@c itigroup.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
I am using an STL queue ( on top of a vector ).

queue < BroadcastBuffer *, vector <BroadcastBuffe r*> > queue;

Is there anyway of flushing the queue - clear() is not available.


#include <iostream>
#include <queue>

int main()
{
std::queue<int> q;
q.push(42);
std::cout << q.size() << '\n';

q = std::queue<int> ();
std::cout << q.size() << '\n';

return 0;
}

-Mike
Sep 29 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2300
by: Tino | last post by:
I have a std::vector<int> which, after some initialization, has a fixed number of elements...after initialization I must do the following repeatedly: I remove an element which could be anywhere in the vector, and add another element which will always be at the end, ie. vector<int> v; int i, x; .... initialization
6
8015
by: Jason Heyes | last post by:
What is a good way of removing elements from std::vector so that the elements removed satisfy a predicate and end up stored in another std::vector. It seems as though the algorithm std::remove_if only achieves half the job. Here is how I would use std::remove_if to remove elements from std::vector based on predicate: v.erase(std::remove_if(v.begin(), v.end(), pred), v.end()); After that line is executed I cannot get back the elements...
2
1428
by: Graham | last post by:
Hi all, I'm trying to clean up the output from Word that has been pasted into a textarea. I'm purging much of the html (all styles, attributes etc) and would also like to remove things like vector graphics. To do this I want to simply drop all elements (or their children) which are in any namespace other than the default: all the microsoft-specific o:p, v:drawLine, etc tags. But I can't persuade javascript to even see the namespaces!...
7
2098
by: Adam Hartshorne | last post by:
Hi All, I was wondering if somebody could tell me if there is an efficient way to do the following. Say I have a list(or vector) A and a list B, I want to remove any elements in B, that are also elements in A. Adam
2
1707
by: Adam Hartshorne | last post by:
Hi All, I was wondering if somebody could tell me if there is an efficient way to do the following. Say I have a list(or vector) A and a list B, I want to remove any elements in B, that are also elements in A. Adam
6
1530
by: Alien | last post by:
According to MSDN, removing elements invalidates only those iterators that had specifically pointed at the removed elements. But I tried following codes, and find that without the repeated it=map_.begin(); there will be memory violation. So, the iterator IS invalidated even if it's not the removed one. why? -----------
11
1991
by: kaferro | last post by:
I cannot relieve that I am working on Thanksgiving, but I am stuck over something that should be simple. I have a vector that has twenty-four elements. I need to remove the four elements whose positions equal zero. The code below only removes two of the four. Any ideas? logfile << "\n\n\n. . .removing flat positions"; logfile << "vector size=" << componentPerformance.size() << endl; int position=0;
10
6059
by: arnuld | last post by:
WANTED: /* C++ Primer - 4/e * * Exercise: 9.26 * STATEMENT * Using the following definition of ia, copy ia into a vector and into a list. Use the single iterator form of erase to remove the elements with odd values from your list * and the even values from your vector.
2
1410
by: =?Utf-8?B?VG9kZCBCZWF1bGlldQ==?= | last post by:
Hello, I have a list of elements and I want to perform an operation on a subset of them and then remove them from the list. If I build a sequence of elements via LINQ to drive the enumeration, as soon as I remove the first element the enumeration operation is broken. This surprises me. I thought the LINQ'd sequence would be its own collection, impervious to changes in the original source collection.
5
1646
Aimee Bailey
by: Aimee Bailey | last post by:
In a library I am writing, I wish to stop people from removing item's from an List<> collection, is there an alternative or a way of overloading the Remove method that would stop other developers removing elements? Aimee.
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4159
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.