473,395 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

questions about STL erase example

I am reading a STL example:

bool badValue(int x); // return whether x is 'bad'.
vector<int> c;
c.erase( remove_if(c.begin(), c.end(), badValue), c.end());

My question is the above code, does it remove ONLY THE FIRST item where
badValue return false or
ALL ITEMs where badValue return false.

Thank you.

Mar 8 '06 #1
2 1643
Al************@gmail.com wrote:
vector<int> c;
c.erase( remove_if(c.begin(), c.end(), badValue), c.end());

My question is the above code, does it remove ONLY THE FIRST item where
badValue return false or
ALL ITEMs where badValue return false.


It returns all items for which the predicate yields 'true'.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
Mar 8 '06 #2
Al************@gmail.com wrote:
I am reading a STL example:

bool badValue(int x); // return whether x is 'bad'.
vector<int> c;
c.erase( remove_if(c.begin(), c.end(), badValue), c.end());

My question is the above code, does it remove ONLY THE FIRST item where
badValue return false or
ALL ITEMs where badValue return false.


I believe it removes all "bad" items.
Mar 8 '06 #3

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

Similar topics

11
by: dw85745 | last post by:
PROBLEMS I Haven't solved: 1. Timing issue between real-time server #1 and my drawing tools. Will moving the tools (currently within module) to an ActiveX (exe or DLL) solve the problem or...
5
by: Laser Lu | last post by:
Can we define events in a class when coding using VBScript in ASP? I still have the second question, even if the answer is positive. That is whether the two standard events of a calss module in VB,...
12
by: Ross Boylan | last post by:
I am trying to understand under what circumstances destructors get called with std::vector. I have an application in which I will put real objects, not just pointers, in the vector. 1. The...
9
by: Pavel Stehule | last post by:
Hello I try tsearch2 within czech environment. It is works fine, but I have two questions. 1. I have words "se", "ve" in my czech stop words. But I get this words in result. Why? Have I...
20
by: Tom van Stiphout | last post by:
I'm about to write a function like below, which I'm going to call a lot of times. So I care about possible memory leaks. I think whether I should use Erase or not depends on whether Split creates...
7
by: al.cpwn | last post by:
Is there a reason why erase for vector returns an iterator but erase for set doesn't? Is this something we should keep in mind while designing our own containers (like binary tree for example)?
8
by: olanglois | last post by:
Hi, I was asking myself to following question. What is better to erase an element from a STL map: calling (option #1) size_type erase(const key_type& k) or calling (option #2)
3
by: Adrian | last post by:
I have some class to read and store options from a config file. I have a design which works for the basic types. What I want to add is an array like type. I am not sure how to define the Field...
4
by: sks | last post by:
I have a question regarding std::multimap/iterators. At the SGI website, it says "Erasing an element from a multimap also does not invalidate any iterators, except, of course, for iterators that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.