220 7182 <2d16db0e-fb46-4e1f-956f-db3407a6fb4c@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Vlad from Moscow <vlad.moscow@mail.ru>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: "count_while" and "count_until" algorithms
Date: Tue, 8 Oct 2013 13:56:01 -0700 (PDT)
Lines: 136
Approved: news@gmane.org
Message-ID: <2d16db0e-fb46-4e1f-956f-db3407a6fb4c@isocpp.org>
References: <CAOpASk64dV+3ZUW+Z8wcEqug_oSaztvJp1zsDB_QdAxi+fwcsA@mail.gmail.com>
 <fe7981d7-4eaf-4132-9150-4ec7d3ff7ac4@isocpp.org>
 <2602b3fd-fccd-459b-be1a-93a12005dc5c@isocpp.org>
 <231e6ef1-599d-4877-be6c-55e85e5a4e41@isocpp.org>
 <6e15fc38-8be3-4e74-ade9-e25a8d0e0509@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_321_28098160.1381265762012"
X-Trace: ger.gmane.org 1381265764 14956 80.91.229.3 (8 Oct 2013 20:56:04 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 8 Oct 2013 20:56:04 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCXLLRHD7IDRBY7C2GJAKGQEVNT7UMQ@isocpp.org Tue Oct 08 22:56:08 2013
Return-path: <std-proposals+bncBCXLLRHD7IDRBY7C2GJAKGQEVNT7UMQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f200.google.com ([209.85.214.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBY7C2GJAKGQEVNT7UMQ@isocpp.org>)
	id 1VTeK5-0007O5-8F
	for gclcip-std-proposals@m.gmane.org; Tue, 08 Oct 2013 22:56:05 +0200
Original-Received: by mail-ob0-f200.google.com with SMTP id wo20sf4548519obc.11
        for <gclcip-std-proposals@m.gmane.org>; Tue, 08 Oct 2013 13:56:04 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=V5nNehSuSMyVAOmZahTAASDl4lOooXEBmMjzCdNLMWg=;
        b=AcfDyA+wda1KzqYIGe6jWL07BCQ8LJeEO/wjUQC1i1NlIT9BqRMVBtXRK196N3va2x
         KZ8/cTGU/Mb3x8HPi7pwSAyMKS4kc5J/iJYE4psnnUEZdUnwW5KWkYMFDpx0dQ+v6rb6
         rO4mlNxNGjlMBjHjPtSf9CCFzUxITeVM6Yz/Patqv9R2dO0Zv7VkBXwh4bi0Ix76WGRU
         Sj2DzZxbHEX0TsGPA4dqjx3FPR6DQ0k3jeFlQolRQZTAJ7Pc2OGPTLhOYmu9Q7Eiy/2d
         mi6Gvw+Oj10UUZ9NwlyZdwwTBzy8lNTWJe+TVerRXAj+NyiCztcjx1vVYb84v8rcdkk0
         QfVQ==
X-Received: by 10.50.73.37 with SMTP id i5mr19340795igv.2.1381265764247;
        Tue, 08 Oct 2013 13:56:04 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.43.232 with SMTP id z8ls3927263igl.32.canary; Tue, 08 Oct
 2013 13:56:03 -0700 (PDT)
X-Received: by 10.50.23.8 with SMTP id i8mr1072103igf.8.1381265763709;
        Tue, 08 Oct 2013 13:56:03 -0700 (PDT)
In-Reply-To: <6e15fc38-8be3-4e74-ade9-e25a8d0e0509@isocpp.org>
X-Original-Sender: vlad.moscow@mail.ru
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:7182
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/7182>

------=_Part_321_28098160.1381265762012
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I want to change the name in the context of my proposal of=20
std::accumulate_first_if that there will be a common name for such types of=
=20
algorithms.
=20
By the way using std::find_if with a predicate resolves the two tasks:=20
returning the count and the last iterator.
=20
For example
=20
[code]
  int a[] =3D { 1, 2, 3, 4, 0, 5 };
  size_t n =3D 0;
  std::find_if( std::begin( a ), std::end( a ),=20
             [&]( int x ) { return ( !( x =3D=3D 0 ) ? ++n, false : true );=
 } );
  std::cout << n << std::endl;
 [/code]
=20

=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=
=8F 2013 =D0=B3., 0:42:56 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=
=D0=B0=D1=82=D0=B5=D0=BB=D1=8C lefev...@gmail.com=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:

> @Evgeny: Yes, I see the advantage to return both count and iterator, but =
I=20
> didn't find an elegant way to do it for the moment.
>
> @Vlad: Why do you want to change the names?
>
>
>
> Le mardi 8 octobre 2013 22:36:57 UTC+2, Evgeny Panasyuk a =C3=A9crit :
>>
>> 9 oct 2013 =D0=B3., 0:33:18 UTC+4 lefev...@gmail.com :
>>>
>>> Yes, the behavior is like find_if + distance, but the performance is=20
>>> better (except maybe for random access iterator). I propose a template=
=20
>>> specialization for random access iterator in order to be at least as fa=
st=20
>>> as find_if + distance.
>>>
>>> Le mardi 8 octobre 2013 22:27:10 UTC+2, Evgeny Panasyuk a =C3=A9crit :
>>>>
>>>> I think to make it useful - both count and iterator should be returned=
..=20
>>>> Just think what happens when input range is single pass.
>>>> Plus, maybe special versions for RandomAccessIterator via compile time=
=20
>>>> dispatch (with better performance) .
>>>>
>>>
>> Just to clarify: do you see that both count and iterator should be=20
>> returned?
>>
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_321_28098160.1381265762012
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I want to change the name in the context of my propos=
al of std::accumulate_first_if that there will be a common name for such ty=
pes of algorithms.</div><div>&nbsp;</div><div>By the way using std::find_if=
 with a predicate resolves the two tasks: returning the count and the last =
iterator.</div><div>&nbsp;</div><div>For example</div><div>&nbsp;</div><div=
>[code]<br>&nbsp;&nbsp;int a[] =3D { 1, 2, 3, 4, 0, 5 };</div><div>&nbsp;&n=
bsp;size_t n =3D 0;</div><div>&nbsp;&nbsp;std::find_if( std::begin( a ), st=
d::end( a ), <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp; [&amp;]( int x ) { return ( !( x =3D=3D 0 ) ? ++n, false : t=
rue ); } );</div><div>&nbsp;&nbsp;std::cout &lt;&lt; n &lt;&lt; std::endl;<=
br>&nbsp;[/code]<br></div><div>&nbsp;</div><div><br>=D1=81=D1=80=D0=B5=D0=
=B4=D0=B0, 9 =D0=BE=D0=BA=D1=82=D1=8F=D0=B1=D1=80=D1=8F 2013&nbsp;=D0=B3., =
0:42:56 UTC+4 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=
=D0=BB=D1=8C lefev...@gmail.com =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:=
</div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex;=
 padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-widt=
h: 1px; border-left-style: solid;"><div dir=3D"ltr"><span><span style=3D"co=
lor: rgb(34, 34, 34);"></span></span>@Evgeny: Yes, I see the advantage to r=
eturn both count and iterator, but I didn't find an elegant way to do it fo=
r the moment.<br><br>@Vlad: Why do you want to change the names?<br><br><br=
><br>Le mardi 8 octobre 2013 22:36:57 UTC+2, Evgeny Panasyuk a =C3=A9crit&n=
bsp;:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; =
padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width=
: 1px; border-left-style: solid;"><div dir=3D"ltr">9 oct 2013&nbsp;=D0=B3.,=
 0:33:18 UTC+4 <a>lefev...@gmail.com</a> :<blockquote class=3D"gmail_quote"=
 style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: =
rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div=
 dir=3D"ltr">Yes, the behavior is like find_if + distance, but the performa=
nce is better (except maybe for random access iterator). I propose a templa=
te specialization for random access iterator in order to be at least as fas=
t as find_if + distance.<br><br>Le mardi 8 octobre 2013 22:27:10 UTC+2, Evg=
eny Panasyuk a =C3=A9crit&nbsp;:<blockquote class=3D"gmail_quote" style=3D"=
margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 2=
04, 204); border-left-width: 1px; border-left-style: solid;"><div dir=3D"lt=
r">I think to make it useful - both count and iterator should be returned. =
Just think what happens when input range is single pass.<br>Plus, maybe spe=
cial versions for RandomAccessIterator via compile time dispatch (with bett=
er performance) .<br></div></blockquote></div></blockquote><div><br><span l=
ang=3D"en"><span>Just to clarify</span></span>: do you see that  both count=
 and iterator should be returned?</div></div></blockquote></div></blockquot=
e></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_321_28098160.1381265762012--

.
