Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113061 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31380 invoked from network); 3 Feb 2021 15:54:36 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Feb 2021 15:54:36 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2C0C71804B1 for ; Wed, 3 Feb 2021 07:38:07 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_05, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 3 Feb 2021 07:38:03 -0800 (PST) Received: by mail-lj1-f170.google.com with SMTP id c18so28791721ljd.9 for ; Wed, 03 Feb 2021 07:38:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=R9Q9pQmvyEBOlattJewfuxv+QL+yQ+vHO6QkUWmBBDs=; b=D1ZMvaKKaSBJbUV+2/vo2UYpbhpTkPVkr1Iiaci1M9RNCjjcRcAHHJHaiWW/IB7syg X4xxCWJHOctgY3RYifaia7hmWC6bZLSMGuWf9Z4bHfLk2gbKCI6ZalyKbbgEuOFuSJUZ 10gXHdjmbjb2HJLlSB2JbCkgVOmce0T0IdeuXDZPrV004YO7IVIh+TkE5ZF+b2flO/ZH 7JdJsmU9kfv/UzQWaOtJ+3DcrRstS5xlXsu2mKLJPyybj5mT6BJFJwHRWYCqvPHJ7xo0 EUWwBvf7NoIshHK3gP1qzo34rcLCwcLdxP6dmUCoJSrCgb1PCPCU8TPV4Tc+qqXi+fYq 9q6g== X-Gm-Message-State: AOAM531AZXHYvPAT5iVCsCiKedIzKIhzmQMndHT1vOzQHD94eBrO+/Mt /kEfB4Jaa8y6QwEoqmaeB3lbyEw9eaNIDgvdzoSj1WoSZKU= X-Google-Smtp-Source: ABdhPJw1+pd0R7HMIsLIGIMwrMPAzL6df5bw/oIndiSk+Ny6YR2NwjNUWKJsJLPyEVYKwhUBlDCPiYZqTRaAC0bNcEQ= X-Received: by 2002:a05:651c:151:: with SMTP id c17mr2056900ljd.246.1612366678515; Wed, 03 Feb 2021 07:37:58 -0800 (PST) MIME-Version: 1.0 Date: Wed, 3 Feb 2021 08:37:41 -0700 Message-ID: To: internals Content-Type: text/plain; charset="UTF-8" Subject: Proposal: Add ReverseArrayIterator and ForwardArrayIterator to SPL From: levim@php.net (Levi Morrison) Hello, everyone! This proposal adds two new classes to the SPL: - `Spl\ReverseArrayIterator`. It iterates over an array in reverse order. It does not duplicate the array. - `Spl\ForwardArrayIterator`. It iterates over an array in forward (normal) order. It does not duplicate the array. They both implement Countable which returns the `count()` of the array. The [PR][1] has some examples and discusses why I am proposing `ForwardArrayIterator` when there is already `ArrayIterator`, the short of which is for performance. There are timing numbers in [one of the comments][2]. When it comes time to vote I may merge this into another RFC with [`CachedIterable` by Tyson Andre][3], which I recommend readers also take a look at. Whether we team up for the RFC vote or not, I wanted to get this out there for discussion and review. [1]: https://github.com/php/php-src/pull/6535 [2]: https://github.com/php/php-src/pull/6535#issuecomment-769179450 [3]: https://github.com/php/php-src/pull/6655