https://github.com/swiftlang/swift-se0270-range-set
Swift Evolution preview package for SE-0270.
https://github.com/swiftlang/swift-se0270-range-set
Last synced: about 1 month ago
JSON representation
Swift Evolution preview package for SE-0270.
- Host: GitHub
- URL: https://github.com/swiftlang/swift-se0270-range-set
- Owner: swiftlang
- License: apache-2.0
- Created: 2020-02-06T17:24:14.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-17T21:22:21.000Z (11 months ago)
- Last Synced: 2025-04-07T13:06:10.420Z (2 months ago)
- Language: Swift
- Size: 36.1 KB
- Stars: 20
- Watchers: 142
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# SE0270_RangeSet
**SE0270_RangeSet** is a standalone library that implements the Swift Evolution proposal
[SE-0270: Add Collection Operations on Noncontiguous Elements][proposal].
You can use this package independently,
or as part of the [standard library preview package][stdlib-preview].## Functionality
**SE0270_RangeSet** provides operations on noncontiguous subranges of collections,
such as `subranges(where:)` and `moveSubranges(_:to:)`,
as well as the supporting `RangeSet` type.```swift
import SE0270_RangeSetvar numbers = [10, 12, -5, 14, -3, -9, 15]
let negatives = numbers.subranges(where: { $0 < 0 })
// numbers[negatives].count == 3numbers.moveSubranges(negatives, to: 0)
// numbers == [-5, -3, -9, 10, 12, 14, 15]
```## Usage
You can add this library as a dependency to any Swift package.
Add this line to the `dependencies` parameter in your `Package.swift` file:```swift
.package(
url: "https://github.com/apple/swift-se0270-range-set",
from: "1.0.0"),
```Next, add the module as a dependency for your targets that will use the library:
```swift
.product(name: "SE0270_RangeSet", package: "swift-se0270-range-set"),
```You can now use `import SE0270_RangeSet` to make the library available in any Swift file.
## Contributing
We are no longer taking contributions to this repo. Please see the
[guide for Contributing to Swift][contributing] for other opportunities within the Swift
project. Thanks to all past contributors![proposal]: https://github.com/apple/swift-evolution/blob/master/proposals/0270-rangeset-and-collection-operations.md
[stdlib-preview]: https://github.com/apple/swift-standard-library-preview
[user-forums]: https://forums.swift.org/c/swift-users/
[bugs]: https://bugs.swift.org
[evolution-process]: https://github.com/apple/swift-evolution/blob/master/process.md
[contributing]: https://swift.org/contributing