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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to