---
title: LazyPrefixWhileSequence
framework: swift
role: symbol
role_heading: Structure
path: swift/lazyprefixwhilesequence
---

# LazyPrefixWhileSequence

A sequence whose elements consist of the initial consecutive elements of some base sequence that satisfy a given predicate.

## Declaration

```swift
@frozen struct LazyPrefixWhileSequence<Base> where Base : Sequence
```

## Overview

Overview note: When LazyPrefixWhileSequence wraps a collection type, the performance of accessing endIndex depends on how many elements satisfy the predicate at the start of the collection, and might not offer the usual performance given by the Collection protocol. Accessing endIndex, the last property, or calling methods that depend on moving indices might not have the documented complexity.

## Topics

### Type Aliases

- [LazyPrefixWhileSequence.Element](swift/lazyprefixwhilesequence/element.md)

### Default Implementations

- [BidirectionalCollection Implementations](swift/lazyprefixwhilesequence/bidirectionalcollection-implementations.md)
- [Collection Implementations](swift/lazyprefixwhilesequence/collection-implementations.md)
- [LazySequenceProtocol Implementations](swift/lazyprefixwhilesequence/lazysequenceprotocol-implementations.md)
- [Sequence Implementations](swift/lazyprefixwhilesequence/sequence-implementations.md)

## Relationships

### Conforms To

- [BidirectionalCollection](swift/bidirectionalcollection.md)
- [Collection](swift/collection.md)
- [Copyable](swift/copyable.md)
- [Escapable](swift/escapable.md)
- [LazyCollectionProtocol](swift/lazycollectionprotocol.md)
- [LazySequenceProtocol](swift/lazysequenceprotocol.md)
- [Sequence](swift/sequence.md)

## See Also

### Lazy Wrappers

- [LazySequence](swift/lazysequence.md)
- [LazyMapSequence](swift/lazymapsequence.md)
- [LazyFilterSequence](swift/lazyfiltersequence.md)
- [LazyDropWhileSequence](swift/lazydropwhilesequence.md)
- [LazyCollection](swift/lazycollection.md)
- [LazyDropWhileCollection](swift/lazydropwhilecollection.md)
- [LazyFilterCollection](swift/lazyfiltercollection.md)
- [LazyMapCollection](swift/lazymapcollection.md)
- [LazyPrefixWhileCollection](swift/lazyprefixwhilecollection.md)
