mirror of
https://github.com/apple/swift-collections
synced 2026-11-28 05:04:21 +00:00
Add BidirectionalContainer.spanBoundary(before:maxDistance:limitedBy:) and make it the core primitive
This commit is contained in:
10 files changed
+214
-76
No files matched your search
@@ -409,15 +409,26 @@ extension UniqueArray where Element: ~Copyable {
|
||||
}
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
public func spanBoundary(before index: Index, maxDistance: Int) -> Index? {
|
||||
_storage.spanBoundary(before: index, maxDistance: maxDistance)
|
||||
public func spanBoundary(
|
||||
before index: Index
|
||||
) -> (index: Index, distance: Int) {
|
||||
_storage.spanBoundary(before: index)
|
||||
}
|
||||
|
||||
@inlinable
|
||||
@_alwaysEmitIntoClient
|
||||
public func spanBoundary(
|
||||
before index: Index, maxDistance: Int, limitedBy limit: Index
|
||||
) -> (index: Index, distance: Int) {
|
||||
_storage.spanBoundary(
|
||||
before: index, maxDistance: maxDistance, limitedBy: limit)
|
||||
}
|
||||
|
||||
@_alwaysEmitIntoClient
|
||||
@_lifetime(borrow self)
|
||||
public func previousSpan(
|
||||
before index: inout Int, maxCount: Int
|
||||
) -> Span<Element> {
|
||||
// FIXME: Remove this in favor of the BidirectionalContainer algorithm.
|
||||
_storage.previousSpan(before: &index, maxCount: maxCount)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user