Contents

ReversedCollection

A collection that presents the elements of its base collection in reverse order.

Declaration

@frozen struct ReversedCollection<Base> where Base : BidirectionalCollection

Overview

The reversed() method is always lazy when applied to a collection with bidirectional indices, but does not implicitly confer laziness on algorithms applied to its result. In other words, for ordinary collections c having bidirectional indices:

  • c.reversed() does not create new storage

  • c.reversed().map(f) maps eagerly and returns a new array

  • c.lazy.reversed().map(f) maps lazily and returns a LazyMapCollection

Topics

Instance Methods

Default Implementations

See Also

Wrappers for Algorithms