From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Trait based containers Date: Mon, 7 May 2018 09:14:22 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <619088663.547202536.622332.laguest-archeia.com@nntp.aioe.org> <3de7cff3-9cfa-44bc-b837-5048bd813802@googlegroups.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:52063 Date: 2018-05-07T09:14:22+02:00 List-Id: On 07/05/2018 09:02, briot.emmanuel@gmail.com wrote: > I prefer to return a key in the "for..of" loop case, because with a map you > can always go from key->element. The opposite might not be true. The main purpose of iteration is not to use keys and thus to avoid to the overhead of key-to-element mapping and, possibly, the volatility of keys. Actually in most cases there should no iterators at all but an array view of the container instead. Iterators is a necessary evil of half-containers like lists, graphs etc. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de