220 37484 <CAOfiQqmXRRssuztELOmn53AHmH5zRMoW4F1iMXjkT7vXDLjBLA@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Richard Smith <richard@metafoo.co.uk>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Adding 'apply_permutation' functions to the
 standard library
Date: Mon, 26 Mar 2018 16:16:23 -0700
Lines: 158
Approved: news@gmane.org
Message-ID: <CAOfiQqmXRRssuztELOmn53AHmH5zRMoW4F1iMXjkT7vXDLjBLA@mail.gmail.com>
References: <9d30f89e-c92f-4c38-9943-b96b199d1ddd@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="f4f5e808e164a0535b056858f766"
X-Trace: blaine.gmane.org 1522106089 32568 195.159.176.226 (26 Mar 2018 23:14:49 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 26 Mar 2018 23:14:49 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDVNBJG4YAIBBYP64XKQKGQEBN5TL5A@isocpp.org Tue Mar 27 01:14:45 2018
Return-path: <std-proposals+bncBDVNBJG4YAIBBYP64XKQKGQEBN5TL5A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f198.google.com ([209.85.128.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDVNBJG4YAIBBYP64XKQKGQEBN5TL5A@isocpp.org>)
	id 1f0bK6-0008MX-VQ
	for gclcip-std-proposals@m.gmane.org; Tue, 27 Mar 2018 01:14:43 +0200
Original-Received: by mail-wr0-f198.google.com with SMTP id v11sf4654976wri.13
        for <gclcip-std-proposals@m.gmane.org>; Mon, 26 Mar 2018 16:16:50 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1522106210; cv=pass;
        d=google.com; s=arc-20160816;
        b=NRGyO53o3F0eMwk05DZuV4HOB8cW6PpQlsbP49uUbgBOfJIJ+8rD38tbNho8kEpn9n
         aRzTnm870l6nFzWgK+wMPy6ZVmv6VhDepy0vOnzOcMYI5Y9XGWoPA54aNegRyZQqjUGm
         gf9crGXdpwQeGygjtsRyUa+cabJ0NtsMoUZa+g00sFOCD+yoao7f9bFfDDYyvxt1f2bN
         6bmJCv8JAJWpHtca9kfNjQ00Wu8AJM39RqWLlozmwQ81rnik4+SYtui2B9mNbYkj5k8U
         o7voWTJC/Y7rtS/vBgXxU06qIxCEpNai4TxzxSM7IUa+WNoeL61kGiwoGz98ayXpihQk
         XGBQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=UYzVNUr7X0Rwh0e3BLwSLNyloCn6LvcSN9sPXrqX21k=;
        b=iRvCfjEnkIuIOny/2xH7f45jMlhSzdeJ20rolH4uE+DiP5wRa6e6tdJop5uUzJTSCg
         nnNJvX/h9DMUixkfxaskwRZBnCMXrnp2roAwQvJV/2MP96NohDbKQqAOZeG4p8yjQovZ
         FhmVP52QUpfMxwNkOMViI9FM9La4zXNxXo87hux8wBTn2ZuTIuxu2uzGf6uPZU2DTxWd
         27qX8zk/9Wft/I9oxyyVVWIfD2BdO5nHI3RZA4bjXO7e9cxVa/FyNTgEA3D58w+GczGn
         yFn0Qz9qPpF8l/6/rI8GC/AwChVCpvwqHpvv9+4gg5291FtAmxPHbsQj943okxEs7ixj
         aJFQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@metafoo.co.uk header.s=default header.b=lwmJWMHP;
       spf=neutral (google.com: 81.27.85.19 is neither permitted nor denied by best guess record for domain of richard@metafoo.co.uk) smtp.mailfrom=richard@metafoo.co.uk
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=UYzVNUr7X0Rwh0e3BLwSLNyloCn6LvcSN9sPXrqX21k=;
        b=hLq67/jHgJaKQnoab05Yh8OBaZ5yO08X+uCciYdlERlfA7xVVe4Sc9B7yaRovRQ09X
         8soCIEqabkANYYkyAn6yit/xvkk/Zu+LD0sO+EMOl7s7KwNtsSA4YDY0TXnHlGNWoS4M
         xd5ud9NhPBp7AFuh9bGggrfNYkJMr0P6TTJxCxfiLDFB/NfilGLF7FqQvZTo44hxyhLk
         vF7UJdlRIBjmFkqL8Uxi5CrKXkjHRWcsLeWlDrpqqYeXrmoiqi1mFv4vx8ZCtUdX9He0
         N7uVo3Oy96H0DrWRr5C3mMt3GBSQ6qwZdlJGkJH8SbYMrVi8GFaSEOaB5FHeqamP32gq
         Ke9w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=UYzVNUr7X0Rwh0e3BLwSLNyloCn6LvcSN9sPXrqX21k=;
        b=mMcr+TxWpk+0T8wtaToG/2IU2QpCRFn3lig2+h0SsxH3C8XD1/fZlBdhl/jF65D7vs
         Qtde7JeKuO1uoex+cwEuDtaJ7e3huwP+NCNMA1J0z5MjG6R8ebL9OMYL7p/CHbFYF8WS
         KA084Gynj8he4Jrbtg4pXvv0l+eWenwFoAON/y/ioInG/okcG9F4TpELuLve+K8cVuUw
         IpjtaG+qmxSwqL+Tyg1BK8pJ/6P02nq4CrS81fflmJDU17ajgkPGdIGA/dci5WBx9fIF
         7rJDiJU9uDLkYehJwecQf9JAqnyPXBKN3Pt4KjupeAklLUN1PyvD/APXQZUgFZT31GBY
         9/Ww==
X-Gm-Message-State: AElRT7Eq0/PwJ11b2mnYCszOL8oKE3kBsOzsImWWud5EYz7EqCd0/5rJ
	2aykNQeOEZ4lxaqmdIyzoWFDwg==
X-Google-Smtp-Source: AIpwx48xXpuqGP/n2yuM5TGx+2WwlMBiOKFtXRj7hO5//EiRQVoPIwlI1XV+ifW2BNr9BBMe88kqDg==
X-Received: by 10.223.180.87 with SMTP id v23mr7721wrd.12.1522106210465;
        Mon, 26 Mar 2018 16:16:50 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.199.141 with SMTP id x135ls1441902wmf.10.gmail; Mon, 26 Mar
 2018 16:16:49 -0700 (PDT)
X-Received: by 10.28.101.6 with SMTP id z6mr15263153wmb.110.1522106209264;
        Mon, 26 Mar 2018 16:16:49 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1522106209; cv=none;
        d=google.com; s=arc-20160816;
        b=vxXatz66nlCgZXtnsXl1eWHKBxEEdmthL5mJAG9adqKG99kDBYVGZnNN1GhFThr5BG
         RhHrc05saw1RulKyAMTuK6IszhVldPw282G42Ppe0WdminB5YjG3s433sKvqUOMHaxCY
         UHJBbwYRP+RcntIaaE4tsXZxSbgyrDu/2y1JUD7HXBz2CjCzP8MzNXaueldEGoJeKBzE
         r1PjHozzYkPHX4G2Qs/XyLdgqK3ptSwx8dQn+SXG8UFr+cE3BrebtP/FbX6dOvsQd8TZ
         Q9306KM3e12x84mt+BQRW1NpmasXmPAwMMUjPruEASym5uIU3C+itXtbrLSJJXb7ff4Q
         lcng==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=upRMGFtuc6ujWjHv0abE9cAutMEbIdjzE3+OCjeusgY=;
        b=mzDAKY0VbODHJpb/pwmCoSpJwD2ah8C23KV2/G11YY4WyvEivB+5nOryoAMvwUqkk5
         LhnIPAWjzeX0bF/SvZgI/rfRBBvk0PMVv3W+RV7/XJtE79dXGhT5ScuLGsKWViNWFdCo
         kNRM53cdDCId1Yr+zV2KqU0V6Z2mudVdP6VmUyn4GyHELiVvuAWZMQMNAcs7fBnDjJUL
         Mg5gRH9mqM9Q7WMLxDhGyNVRv40UfOSxgxXNVZcArRMzIApVqI6Jdjz3eb/c4yrXphe5
         JWI63n7buGVrvkEMTBCdBF40Ml6K4Qv+NEiz/smy/6W3R4DTFX/L6YBqZQqv8/abyljb
         wFcQ==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@metafoo.co.uk header.s=default header.b=lwmJWMHP;
       spf=neutral (google.com: 81.27.85.19 is neither permitted nor denied by best guess record for domain of richard@metafoo.co.uk) smtp.mailfrom=richard@metafoo.co.uk
Original-Received: from uk12.easy-internet.co.uk (uk12.easy-internet.co.uk. [81.27.85.19])
        by mx.google.com with ESMTPS id o46si12059748wrf.103.2018.03.26.16.16.49
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 26 Mar 2018 16:16:49 -0700 (PDT)
Received-SPF: neutral (google.com: 81.27.85.19 is neither permitted nor denied by best guess record for domain of richard@metafoo.co.uk) client-ip=81.27.85.19;
Original-Received: from mail-oi0-f44.google.com ([209.85.218.44]:38577)
	by uk12.easy-internet.co.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128)
	(Exim 4.89_1)
	(envelope-from <richard@metafoo.co.uk>)
	id 1f0bM4-0000ir-MK
	for std-proposals@isocpp.org; Tue, 27 Mar 2018 00:16:48 +0100
Original-Received: by mail-oi0-f44.google.com with SMTP id c3-v6so17592274oib.5
        for <std-proposals@isocpp.org>; Mon, 26 Mar 2018 16:16:45 -0700 (PDT)
X-Received: by 10.202.9.15 with SMTP id 15mr3271208oij.36.1522106204441; Mon,
 26 Mar 2018 16:16:44 -0700 (PDT)
Original-Received: by 10.74.161.35 with HTTP; Mon, 26 Mar 2018 16:16:23 -0700 (PDT)
In-Reply-To: <9d30f89e-c92f-4c38-9943-b96b199d1ddd@isocpp.org>
X-Gmail-Original-Message-ID: <CAOfiQqmXRRssuztELOmn53AHmH5zRMoW4F1iMXjkT7vXDLjBLA@mail.gmail.com>
X-OutGoing-Spam-Status: No, score=0.1
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - uk12.easy-internet.co.uk
X-AntiAbuse: Original Domain - isocpp.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - metafoo.co.uk
X-Get-Message-Sender-Via: uk12.easy-internet.co.uk: authenticated_id: metafooc/from_h
X-Authenticated-Sender: uk12.easy-internet.co.uk: richard@metafoo.co.uk
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Original-Sender: richard@metafoo.co.uk
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@metafoo.co.uk header.s=default header.b=lwmJWMHP;       spf=neutral
 (google.com: 81.27.85.19 is neither permitted nor denied by best guess record
 for domain of richard@metafoo.co.uk) smtp.mailfrom=richard@metafoo.co.uk
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:37484
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37484>

--f4f5e808e164a0535b056858f766
Content-Type: text/plain; charset="UTF-8"

On 26 March 2018 at 10:52, Alexander Zaitsev <zamazan4ik@gmail.com> wrote:

> Hello,
>
> I am working on proposal about adding two new functions to STL:
> 'apply_permutation' and 'apply_reverse_permutation'. In attachments you can
> find this proposal (in PDF and HTML formats). Also you can find them on
> GitHub: https://github.com/ZaMaZaN4iK/ConfsANDProps/tree/master/Proposals
>
> *What is it?*
>
> Shortly, 'apply_permutation' and 'apply_reverse_permutation' are functions
> for reordering elements in a range in some defined order.
>
> *Description*
>
> The routine `apply_permutation` takes a item sequence and a order
> sequence. It reshuffles item sequence according to order sequence. Every
> value in order sequence means where the item comes from. Order sequence
> needs to be exactly a permutation of the sequence [0, 1, ... , N], where N
> is the biggest index in the item sequence (zero-indexed).
>
> The routine `apply_reverse_permutation` takes a item sequence and a order
> sequence. It will reshuffle item sequence according to order sequence.
> Every value in order sequence means where the item goes to. Order sequence
> needs to be exactly a permutation of the sequence [0, 1, ... , N], where N
> is the biggest index in the item sequence (zero-indexed).
>
> *Brief description*
>
> Brief exaplantion is available on Microsoft Developer "Old new thing"
> blog: 1
> <https://blogs.msdn.microsoft.com/oldnewthing/20170102-00/?p=95095>, 2
> <https://blogs.msdn.microsoft.com/oldnewthing/20170103-00/?p=95105>, 3
> <https://blogs.msdn.microsoft.com/oldnewthing/20170104-00/?p=95115>, 4
> <https://blogs.msdn.microsoft.com/oldnewthing/20170109-00/?p=95145>, 5
> <https://blogs.msdn.microsoft.com/oldnewthing/20170110-00/?p=95155>, 6
> <https://blogs.msdn.microsoft.com/oldnewthing/20170111-00/?p=95165>
>
>
>
> Implementation is available in Boost.Algorithm library:
> https://github.com/boostorg/algorithm/blob/develop/
> include/boost/algorithm/apply_permutation.hpp
> So you can play with it on wandbox.org
>
> <http://wandbox.org/>
>
> <http://wandbox.org/>
> Open questions: Naming. I think apply_reverese_permutation isn't nice
> name. Can you suggest anything better?
>

permute and unpermute?

That said, I find it very surprising that this operation mutates the
permutation as well as the sequence being permuted; that seems very likely
to lead to bugs. It seems like it'd be easy to provide permute_copy /
unpermute_copy operations without this limitation (although if you don't do
the permutation in-place, this becomes sufficiently simple that I'm not
sure it warrants inclusion in the standard library).

-- 
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 email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqmXRRssuztELOmn53AHmH5zRMoW4F1iMXjkT7vXDLjBLA%40mail.gmail.com.

--f4f5e808e164a0535b056858f766
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 2=
6 March 2018 at 10:52, Alexander Zaitsev <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:zamazan4ik@gmail.com" target=3D"_blank">zamazan4ik@gmail.com</a>&gt;<=
/span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hello,<div=
><div style=3D"overflow:auto"><div style=3D"max-height:10000px"><div dir=3D=
"ltr"><div><br></div><div>I am working on proposal about adding two new fun=
ctions to STL: &#39;apply_permutation&#39; and &#39;apply_reverse_permutati=
on&#39;. In attachments you can find this proposal (in PDF and HTML formats=
). Also you can find them on GitHub:=C2=A0<a href=3D"https://github.com/ZaM=
aZaN4iK/ConfsANDProps/tree/master/Proposals" rel=3D"nofollow" target=3D"_bl=
ank">https://github.com/ZaM<wbr>aZaN4iK/ConfsANDProps/tree/mas<wbr>ter/Prop=
osals</a></div><div><br></div><div><b>What is it?</b></div><div><b><br></b>=
</div><div>Shortly, &#39;apply_permutation&#39; and &#39;apply_reverse_perm=
utation&#39; are functions for reordering elements in a range in some defin=
ed order.=C2=A0</div><div><br></div><div><b>Description</b></div><div><br><=
/div><div><div>The routine `apply_permutation` takes a item sequence and a =
order sequence. It reshuffles item sequence according to order sequence. Ev=
ery value in order sequence means where the item comes from. Order sequence=
 needs to be exactly a permutation of the sequence [0, 1, ... , N], where N=
 is the biggest index in the item sequence (zero-indexed).</div><div><br></=
div><div>The routine `apply_reverse_permutation` takes a item sequence and =
a order sequence. It will reshuffle item sequence according to order sequen=
ce. Every value in order sequence means where the item goes to. Order seque=
nce needs to be exactly a permutation of the sequence [0, 1, ... , N], wher=
e N is the biggest index in the item sequence (zero-indexed).</div></div><d=
iv><br></div><div><b>Brief description</b></div><div><b><br></b></div><div>=
Brief exaplantion is available on Microsoft Developer &quot;Old new thing&q=
uot; blog: <a href=3D"https://blogs.msdn.microsoft.com/oldnewthing/20170102=
-00/?p=3D95095" target=3D"_blank">1</a>,
<a href=3D"https://blogs.msdn.microsoft.com/oldnewthing/20170103-00/?p=3D95=
105" target=3D"_blank">2</a>,
<a href=3D"https://blogs.msdn.microsoft.com/oldnewthing/20170104-00/?p=3D95=
115" target=3D"_blank">3</a>,
<a href=3D"https://blogs.msdn.microsoft.com/oldnewthing/20170109-00/?p=3D95=
145" target=3D"_blank">4</a>,
<a href=3D"https://blogs.msdn.microsoft.com/oldnewthing/20170110-00/?p=3D95=
155" target=3D"_blank">5</a>,
<a href=3D"https://blogs.msdn.microsoft.com/oldnewthing/20170111-00/?p=3D95=
165" target=3D"_blank">6</a></div>
=09
=09
=09


<div><b><br></b></div><div><b><br></b></div><div><br></div><div>Implementat=
ion is available in Boost.Algorithm library: <font color=3D"#1155cc"><a hre=
f=3D"https://github.com/boostorg/algorithm/blob/develop/include/boost/algor=
ithm/apply_permutation.hpp" target=3D"_blank">https://github.com/boostorg/<=
wbr>algorithm/blob/develop/<wbr>include/boost/algorithm/apply_<wbr>permutat=
ion.hpp</a></font></div><div>So you can play with it on=C2=A0<a href=3D"htt=
p://wandbox.org/" rel=3D"nofollow" target=3D"_blank">wandbox.org<br></a></d=
iv><div><a href=3D"http://wandbox.org/" rel=3D"nofollow" target=3D"_blank">=
<br></a></div><div><a href=3D"http://wandbox.org/" rel=3D"nofollow" target=
=3D"_blank"><br></a></div><div>Open questions: Naming. I think apply_revere=
se_permutation isn&#39;t nice name. Can you suggest anything better?</div><=
/div></div></div></div></div></blockquote><div><br></div><div>permute and u=
npermute?</div><div><br></div><div>That said, I find it very surprising tha=
t this operation mutates the permutation as well as the sequence being perm=
uted; that seems very likely to lead to bugs. It seems like it&#39;d be eas=
y to provide permute_copy / unpermute_copy operations without this limitati=
on (although if you don&#39;t do the permutation in-place, this becomes suf=
ficiently simple that I&#39;m not sure it warrants inclusion in the standar=
d library).</div></div></div></div>

<p></p>

-- <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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOfiQqmXRRssuztELOmn53AHmH5zRMoW4F1i=
MXjkT7vXDLjBLA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOfiQqmXRRssuztE=
LOmn53AHmH5zRMoW4F1iMXjkT7vXDLjBLA%40mail.gmail.com</a>.<br />

--f4f5e808e164a0535b056858f766--

.
