Hello,
I am thinking an efficient way to remove all the elements (says they
are less than 10) from a container vector<int>.
Any suggestion? Thank you. 5 2624
Wing wrote:
Hello,
I am thinking an efficient way to remove all the elements (says they
are less than 10) from a container vector<int>.
Any suggestion? Thank you.
Look into std::remove_if, std::less, std::bind2nd, and the erase-remove
idiom.
Nate
Wing wrote:
I am thinking an efficient way to remove all the elements (says they
are less than 10) from a container vector<int>.
Any suggestion? Thank you.
Any reason not to use std::vector::clear()?
Best regards,
Tom
Nate Barney wrote:
Wing wrote:
Hello,
I am thinking an efficient way to remove all the elements (says they
are less than 10) from a container vector<int>.
Any suggestion? Thank you.
Look into std::remove_if, std::less, std::bind2nd, and the erase-remove
idiom.
Sounds like overkill if the OP wants to remove _all_ the elements.
Best regards,
Tom
Thomas Tutone wrote:
Nate Barney wrote:
>Wing wrote:
>>Hello,
I am thinking an efficient way to remove all the elements (says they are less than 10) from a container vector<int>.
Any suggestion? Thank you.
Look into std::remove_if, std::less, std::bind2nd, and the erase-remove idiom.
Sounds like overkill if the OP wants to remove _all_ the elements.
I first read the question as "How does one remove all elements that are
less than 10?". I suppose it could be read as "How does one remove all
elements of a vector that has fewer than 10 elements?". Well, now the
OP has an answer either way.
Nate
Nate Barney wrote:
Thomas Tutone wrote:
Nate Barney wrote:
Wing wrote: Hello,
I am thinking an efficient way to remove all the elements (says they are less than 10) from a container vector<int>.
Any suggestion? Thank you.
Look into std::remove_if, std::less, std::bind2nd, and the erase-remove
idiom.
Sounds like overkill if the OP wants to remove _all_ the elements.
I first read the question as "How does one remove all elements that are
less than 10?". I suppose it could be read as "How does one remove all
elements of a vector that has fewer than 10 elements?". Well, now the
OP has an answer either way.
Now I understand. I hadn't read the OP's question that way, but after
reading your interpretation I went back and reread the OP's question,
and now I see your point.
Best regards,
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Generic Usenet Account |
last post by:
To settle the dispute regarding what happens when an "erase" method is
invoked on an STL container (i.e. whether the element is merely
removed from the container or whether it also gets deleted in...
|
by: Yngve |
last post by:
Hi!
I have a (newbie) problem wich i would become glad if someone could help me
with.
I have a Vector of pointers to instances of another class. I would like to
remove a position in the...
|
by: Adam Hartshorne |
last post by:
Hi All,
I have the following problem, and I would be extremely grateful if
somebody would be kind enough to suggest an efficient solution to it.
I create an instance of a Class A, and...
|
by: koperenkogel |
last post by:
Dear cpp-ians,
I am working with a vector of structures.
vector <meta_segment> meta_segm (2421500);
and the structure look like:
struct meta_segment
{
float id;
float num;
|
by: Arne Claus |
last post by:
Hi
If've just read, that remove() on a list does not actually remove the
elements, but places them at the end of the list (according to TC++STL
by Josuttis). It also says, that remove returns a...
|
by: happyvalley |
last post by:
Hi,
I want to remove some elements from a vector, the following code
doesn't work, seems it doesn't allow me to remove an element when
iterating the vector. (make sense), just wonder, how to do...
|
by: groups |
last post by:
This small piece of code is troubling me.. is there anything wrong
with it??
After calling this method the contents ot the input vector are
completely screwed..
(CCountedCIG_CountZero() applies...
|
by: mohammaditraders |
last post by:
Write a program which overloads a binary Minus (+) operator,
The program will contain a class Matrix, This class will contain a
private data member Array which store int values. The class will...
|
by: Angus |
last post by:
Hello
I have a vector<int(aRemovecoll) which is a list of the indexes to
be removed from another vector. The other vecotr contains an object -
I will call it SomeObject. So the other vecotr is...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
| |