Searching a vector for a specific value

S

Siegen

Hi.

Could anyone tell me how one can search a vector for a specific value?

std::vector<int> vec;

vec.push_back(1);
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);

How to check whether the number three is in the vector?


I tried "find" but it doesn't appear to be available to "vector".


Any help appreciated.

Regards,

-- Siegen
 
T

Thomas Tutone

Siegen said:
Could anyone tell me how one can search a vector for a specific value?

std::vector<int> vec;

vec.push_back(1);
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);

How to check whether the number three is in the vector?


I tried "find" but it doesn't appear to be available to "vector".


You posted the same question 3 days ago, and got the correct answer
from several people:

http://tinyurl.com/rmozs

That means one of three things: (1) You didn't bother to read the
responses to your questions last time, (2) you are a troll, or (3) you
are a robot that is simply autoposting the question.

Best regards,

Tom
 
S

Siegen

Thomas.

Thanks for :> http://tinyurl.com/rmozs


Rather than trying your "Group Gestapo" act, please consider some more realistic
possibilities such as: my newsreader not "seeing" any replies. Owing to
circumstances beyond my control, I wasn't able to get back to the group for some
36+ hours by which time my I.S.P. had, perhaps, dropped "older" messages.

"Google Groups" is a good, short-term, archive but requires a real email address
as log-in and, therefore, as fodder for spammers.

Thanks,


:> Siegen wrote:
:>
:> > Could anyone tell me how one can search a vector for a specific value?
:> >
:> > std::vector<int> vec;
:> >
:> > vec.push_back(1);
:> > vec.push_back(2);
:> > vec.push_back(3);
:> > vec.push_back(4);
:> >
:> > How to check whether the number three is in the vector?
:> >
:> >
:> > I tried "find" but it doesn't appear to be available to "vector".
:>
:>
:> You posted the same question 3 days ago, and got the correct answer
:> from several people:
:>
:> http://tinyurl.com/rmozs
:>
:> That means one of three things: (1) You didn't bother to read the
:> responses to your questions last time, (2) you are a troll, or (3) you
:> are a robot that is simply autoposting the question.
:>
:> Best regards,
:>
:> Tom

-- Siegen
 
D

Duane Hebert

Siegen said:
Hi.

Could anyone tell me how one can search a vector for a specific value?

std::vector<int> vec;

vec.push_back(1);
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);

How to check whether the number three is in the vector?


I tried "find" but it doesn't appear to be available to "vector".


Any help appreciated.

std::find() ?
 
S

Siegen

Thanks Duane.

I got stuck expecting a member function instead of a general algorithm .
:> std::find() ?
:>
I'm on the right track now.

Regards,


-- Siegen
 
T

Thomas Tutone

Siegen said:
:> Siegen wrote:
:>
:> > Could anyone tell me how one can search a vector for a specific value?
:> >
:> > std::vector<int> vec;
:> >
:> > vec.push_back(1);
:> > vec.push_back(2);
:> > vec.push_back(3);
:> > vec.push_back(4);
:> >
:> > How to check whether the number three is in the vector?
:> >
:> >
:> > I tried "find" but it doesn't appear to be available to "vector".
:>
:>
:> You posted the same question 3 days ago, and got the correct answer
:> from several people:
:>
:> http://tinyurl.com/rmozs
:>
:> That means one of three things: (1) You didn't bother to read the
:> responses to your questions last time, (2) you are a troll, or (3) you
:> are a robot that is simply autoposting the question.

You're welcome.
Rather than trying your "Group Gestapo" act

Hmm, that seems a bit strong.
, please consider some more realistic
possibilities such as: my newsreader not "seeing" any replies. Owing to
circumstances beyond my control, I wasn't able to get back to the group for some
36+ hours by which time my I.S.P. had, perhaps, dropped "older" messages.

"Google Groups" is a good, short-term, archive but requires a real email address
as log-in and, therefore, as fodder for spammers.

Actually, Google Groups does not require a real email address or a
log-in just to read (as opposed to post) - as the link I referred you
to demonstrates.

Anyway, I'm sorry if my actions offended you - as they certainly must
have since you have compared me to Hitler's secret police.

Best regards,

Tom
 
R

Rolf Magnus

Please don't top-post.
On 24 Sep 2006 05:18:25 -0700 "Thomas Tutone" <[email protected]>
wrote:

:> Siegen wrote:
:>
:> > Could anyone tell me how one can search a vector for a specific
:> > value?
:> >
:> > std::vector<int> vec;
:> >
:> > vec.push_back(1);
:> > vec.push_back(2);
:> > vec.push_back(3);
:> > vec.push_back(4);
:> >
:> > How to check whether the number three is in the vector?
:> >
:> >
:> > I tried "find" but it doesn't appear to be available to "vector".
:>
:>
:> You posted the same question 3 days ago, and got the correct answer
:> from several people:
:>
:> http://tinyurl.com/rmozs
:>
:> That means one of three things: (1) You didn't bother to read the
:> responses to your questions last time, (2) you are a troll, or (3) you
:> are a robot that is simply autoposting the question.


Thanks for :> http://tinyurl.com/rmozs


Rather than trying your "Group Gestapo" act, please consider some more
realistic possibilities

The above ones are realistic. I have seen all of them here.
such as: my newsreader not "seeing" any replies. Owing to circumstances
beyond my control, I wasn't able to get back to the group for some 36+
hours by which time my I.S.P. had, perhaps, dropped "older" messages.

Hmm, 36 hours is a very short age for a message to be dropped. Often,
messages need several hours to even distribute through all of Usenet, so
the time window to actually see messages would be quite short if they get
dropped after 36 hours.
Maybe you could switch to a better news server. There are some servers that
can be used for free.
"Google Groups" is a good, short-term, archive but requires a real email
address as log-in and, therefore, as fodder for spammers.

I don't need any log-in to read the archives, so I guess you must be doing
something wrong.
 
D

Duane Hebert

Siegen said:
Thanks Duane.

I got stuck expecting a member function instead of a general algorithm .
:> std::find() ?
:>
I'm on the right track now.

Some containers have specialized algorithms
so you should check there first. If not, then
look at algorithm.
 
S

Siegen

Tom,
I did get a bit "heavy" so I apologise to you for my comparison.
I also apreciate the assistance I obtained from you and the others.

As for the "google" groups, I can just get a "yahoo" or whatever "throw-away"
address I presume.

Cheers,



:>
:> Siegen wrote:
:>
:> >
:> > :> Siegen wrote:
:> > :>
:> > :> > Could anyone tell me how one can search a vector for a specific value?
:> > :> >
:> > :> > std::vector<int> vec;
:> > :> >
:> > :> > vec.push_back(1);
:> > :> > vec.push_back(2);
:> > :> > vec.push_back(3);
:> > :> > vec.push_back(4);
:> > :> >
:> > :> > How to check whether the number three is in the vector?
:> > :> >
:> > :> >
:> > :> > I tried "find" but it doesn't appear to be available to "vector".
:> > :>
:> > :>
:> > :> You posted the same question 3 days ago, and got the correct answer
:> > :> from several people:
:> > :>
:> > :> http://tinyurl.com/rmozs
:> > :>
:> > :> That means one of three things: (1) You didn't bother to read the
:> > :> responses to your questions last time, (2) you are a troll, or (3) you
:> > :> are a robot that is simply autoposting the question.
:>
:> > Thomas.
:> >
:> > Thanks for :> http://tinyurl.com/rmozs
:>
:> You're welcome.
:>
:> > Rather than trying your "Group Gestapo" act
:>
:> Hmm, that seems a bit strong.
:>
:> > , please consider some more realistic
:> > possibilities such as: my newsreader not "seeing" any replies. Owing to
:> > circumstances beyond my control, I wasn't able to get back to the group for some
:> > 36+ hours by which time my I.S.P. had, perhaps, dropped "older" messages.
:> >
:> > "Google Groups" is a good, short-term, archive but requires a real email address
:> > as log-in and, therefore, as fodder for spammers.
:>
:> Actually, Google Groups does not require a real email address or a
:> log-in just to read (as opposed to post) - as the link I referred you
:> to demonstrates.
:>
:> Anyway, I'm sorry if my actions offended you - as they certainly must
:> have since you have compared me to Hitler's secret police.
:>
:> Best regards,
:>
:> Tom

-- Siegen
 
S

Siegen

Aren't you "top-posting"? Why can't I?

Bye the way. When did you actually buy me? You're acting like you own me.

Regards <If I may>



:> Please don't top-post.
:>
:> Siegen wrote:
:>
:> > On 24 Sep 2006 05:18:25 -0700 "Thomas Tutone" <[email protected]>
:> > wrote:
:> >
:> > :> Siegen wrote:
:> > :>
:> > :> > Could anyone tell me how one can search a vector for a specific
:> > :> > value?
:> > :> >
:> > :> > std::vector<int> vec;
:> > :> >
:> > :> > vec.push_back(1);
:> > :> > vec.push_back(2);
:> > :> > vec.push_back(3);
:> > :> > vec.push_back(4);
:> > :> >
:> > :> > How to check whether the number three is in the vector?
:> > :> >
:> > :> >
:> > :> > I tried "find" but it doesn't appear to be available to "vector".
:> > :>
:> > :>
:> > :> You posted the same question 3 days ago, and got the correct answer
:> > :> from several people:
:> > :>
:> > :> http://tinyurl.com/rmozs
:> > :>
:> > :> That means one of three things: (1) You didn't bother to read the
:> > :> responses to your questions last time, (2) you are a troll, or (3) you
:> > :> are a robot that is simply autoposting the question.
:> >
:> >
:> > Thanks for :> http://tinyurl.com/rmozs
:> >
:> >
:> > Rather than trying your "Group Gestapo" act, please consider some more
:> > realistic possibilities
:>
:> The above ones are realistic. I have seen all of them here.
:>
:> > such as: my newsreader not "seeing" any replies. Owing to circumstances
:> > beyond my control, I wasn't able to get back to the group for some 36+
:> > hours by which time my I.S.P. had, perhaps, dropped "older" messages.
:>
:> Hmm, 36 hours is a very short age for a message to be dropped. Often,
:> messages need several hours to even distribute through all of Usenet, so
:> the time window to actually see messages would be quite short if they get
:> dropped after 36 hours.
:> Maybe you could switch to a better news server. There are some servers that
:> can be used for free.
:>
:> > "Google Groups" is a good, short-term, archive but requires a real email
:> > address as log-in and, therefore, as fodder for spammers.
:>
:> I don't need any log-in to read the archives, so I guess you must be doing
:> something wrong.

-- Siegen
 
S

Siegen

:> Some containers have specialized algorithms
:> so you should check there first. If not, then
:> look at algorithm.
Thanks.

Regards,


-- Siegen
 
K

Kai-Uwe Bux

Siegen wrote [top posting corrected]
:> Please don't top-post.
:>
:> Siegen wrote:
:>
:> > On 24 Sep 2006 05:18:25 -0700 "Thomas Tutone"
Aren't you "top-posting"?

Rolf Magnus was not top posting. Those parts of his post that refer to
specific sections of yours were properly posted below the quote they refer
to.
Why can't I?

You can (unfortunately, there is nothing we could do to prevent you :).

However, top posting is just considered poor form around these parts. Most
regulars feel rather strongly about it. In this news group, top posting is
frowned upon.

Bye the way. When did you actually buy me? You're acting like you own me.

You are misinterpreting. "Please don't top post" is not an order to a slave.
It is a (still friendly) reminder of the local customs in this news group.
It is a _reminder_, because the issue is dealt with in the FAQ.


[snip]


Best

Kai-Uwe Bux
 
S

Siegen

Please stop dragging this thread <and me> even further off-topic.

Also, if you do not understand something then please don't re-arrange it. Your
re-arrangement of my post has me replying to Thomas <see "A" below> when I was
actually replying to Rolf. In your unsolicited efforts to maintain "Order", you
are creating Dis-order.

Regards,

:> Siegen wrote [top posting corrected]
:>
:> > On Sun, 24 Sep 2006 16:28:55 +0200 Rolf Magnus <[email protected]>
:> > wrote:
:> > :> Please don't top-post.
:> > :>
:> > :> Siegen wrote:
:> > :>
:> > :> > On 24 Sep 2006 05:18:25 -0700 "Thomas Tutone"
:> [snip]
"A"
:> > Aren't you "top-posting"?
:>
:> Rolf Magnus was not top posting. Those parts of his post that refer to
:> specific sections of yours were properly posted below the quote they refer
:> to.

:> Siegen:
:> > Why can't I?
:>
:> You can (unfortunately, there is nothing we could do to prevent you :).
:>
:> However, top posting is just considered poor form around these parts. Most
:> regulars feel rather strongly about it. In this news group, top posting is
:> frowned upon.

:> Siegen:
:> > Bye the way. When did you actually buy me? You're acting like you own me.

:> Kai-Uwe Bux
:> You are misinterpreting. "Please don't top post" is not an order to a slave.
:> It is a (still friendly) reminder of the local customs in this news group.
:> It is a _reminder_, because the issue is dealt with in the FAQ.
:>
:>
:> [snip]
:>
:>
:> Best
:>
:> Kai-Uwe Bux

-- Siegen
 
K

Kai-Uwe Bux

Siegen said:
Please stop dragging this thread <and me> even further off-topic.

a) Posting etiquette is on-topic.

b) Again, please refer to the FAQ on how to post around here.

Also, if you do not understand something then please don't re-arrange it.
Your re-arrangement of my post has me replying to Thomas <see "A" below>
when I was actually replying to Rolf. In your unsolicited efforts to
maintain "Order", you are creating Dis-order.

No, I did not create disorder: the first two lines of my re-arrangement
read:

Siegen wrote [top posting corrected]
> On Sun, 24 Sep 2006 16:28:55 +0200 Rolf Magnus <[email protected]>
> wrote:
...

it is plain clear that you were replying to a post of Rolf Magnus.


[snip]


Best

Kai-Uwe Bux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top