<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/LazyPrefixWhileCollection",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:s25LazyPrefixWhileCollectiona"
  },
  "title" : "LazyPrefixWhileCollection"
}
-->

# LazyPrefixWhileCollection

A lazy collection wrapper that includes the initial consecutive
elements of an underlying collection that satisfy a predicate.

```
typealias LazyPrefixWhileCollection<T> = LazyPrefixWhileSequence<T> where T : Collection
```

## Discussion> Note: 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)