🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2540

Re: Q: What does find_first_of() do?

#2540
From: Marian Hellema
Date: Mon, 13 Nov 1995 16:12
63 lines
3315 bytes
Dick Menninger <Dick.Menninger@daytonoh.attgis.com> wrote:
>If you compare it with find_end which precedes it,
>this appears to be a typo and should read:
>
>> ==========Marian Hellema, 11/6/95==========
>> 
>> I am not sure what the algorithm find_first_of() does.
>> At first glance I thought it finds the first occurence of an element
>> of a sequence.
>> So if I have:
>> 
>> int v1[10] = { 0,1,2,3,3,5,3,7,8,8 };
>> int v2[3] = {3,6,2 };
>> int *p = find_first_of( v1, v1+10, v2, v2+3 );
>> 
>> it would return an iterator to the first 3.
>> But then I read section 25.1.4 in the april working paper:
>> 
>>       find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
>>                     ForwardIterator2 first2, ForwardIterator2 last2,
>                                                BinaryPredicate pred);
>                                                (^you left this off^)
>
>> 
>>     Returns:
>>     The first iterator i in  the  range  [first1, last1-(last2-first2))
>>     such  that for any non-negative integer n <(last2-first2), the fol-
>>     lowing   corresponding   conditions   hold:   *i   ==  *(first2+=n),
>                                                 *(i+n)  ==  *(first2+=n)
>                                                  ^^^^^
>>     pred(*i,*(first2+n))  == true.  Returns last1 if no such iterator is
>  pred(*(i+n),*(first2+n))  == true
>        ^^^^^
>>     found.
>> 
>
>In your case, it should return v1+10 since {3,6,2} is not a
>subsequence of v1.

Thanks for your reply. Several people have suggested this "typo" in the
draft, but I don't think your interpretation is correct. What you describe as
the behavior of find_first_of()  fits exactly the description of search(),
see 25.1.9 of the standard working paper.

My suspicion, which was confirmed by Samuel Danton, is that the "typo" is
in the phrase "... for any non-negative integer n...". I think this is meant
to be:
".. for some non-negative integer n...".
This interpretation is conform the memberfunction find_first_of() of class
string,
see 21.1.1.9.3 of the working paper.

Regards,
Marian
-- 
----------------------------------------------------------------------
Marian Hellema            AT Computing, UNIX training and consultancy
email: marian@atcmp.nl    P.O. Box 1428, 6501 BK Nijmegen
phone: +31 24 3527225     the Netherlands
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <487ngc$7bd@info.uci.kun.nl>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <47kjd8$eq8@info.uci.kun.nl> <DHuECp.K3u@falcon.daytonoh.attgis.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 13 Nov 95 16:12:38 GMT
Approved: fjh@cs.mu.oz.au
From: Marian Hellema <marian@atcmp.nl>
Newsgroups: comp.std.c++
Subject: Re: Q: What does find_first_of() do?
X-Original-Date: 13 Nov 1995 15:16:28 GMT
Organization: AT Computing, Nijmegen, the Netherlands
Message-ID: <487ngc$7bd@info.uci.kun.nl>
References: <47kjd8$eq8@info.uci.kun.nl> <DHuECp.K3u@falcon.daytonoh.attgis.com>
X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.4 sun4m)
X-Url: news:DHuECp.K3u@falcon.daytonoh.attgis.com
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMKdur+EDnX0m9pzZAQGvKgF/WSyU1U4jSiiTXEOWh5J4CEUFscM1sXN1
 VfFlCZVidCeb8n6pr1n93/2yGHH5zDSu
 =SNIb