Generic Structure

# AnyIterator

A type-erased iterator of `Element`

.

## Overview

This iterator forwards its `next()`

method to an arbitrary underlying iterator having the same `Element`

type, hiding the specifics of the underlying `IteratorProtocol`

.

## Topics

### Initializers

`init<I>(I)`

Creates an iterator that wraps a base iterator but whose type depends only on the base iterator’s element type.

### Instance Methods

`func dropFirst()`

Returns a subsequence containing all but the first element of the sequence.

`func dropFirst(Int)`

Returns a subsequence containing all but the given number of initial elements.

`func dropLast()`

Returns a subsequence containing all but the last element of the sequence.

`func dropLast(Int)`

Returns a subsequence containing all but the given number of final elements.

`func enumerated()`

Returns a sequence of pairs (*n*, *x*), where *n* represents a consecutive integer starting at zero and *x* represents an element of the sequence.

`func joined()`

Returns the elements of this sequence of sequences, concatenated.

`func max()`

Returns the maximum element in the sequence.

`func min()`

Returns the minimum element in the sequence.

`func next()`

Advances to the next element and returns it, or `nil`

if no next element exists.

`func prefix(Int)`

Returns a subsequence, up to the specified maximum length, containing the initial elements of the sequence.

`func reversed()`

Returns an array containing the elements of this sequence in reverse order.

`func suffix(Int)`

Returns a subsequence, up to the given maximum length, containing the final elements of the sequence.

## See Also

### Type-Erasing Wrappers

`struct AnyCollection`

A type-erased wrapper over any collection with indices that support forward traversal.

`struct AnyIndex`

A wrapper over an underlying index that hides the specific underlying type.