Swiftpack.co -  apple/swift-se0270-range-set as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
apple/swift-se0270-range-set
Swift Evolution preview package for SE-0270.
.package(url: "https://github.com/apple/swift-se0270-range-set.git", from: "1.0.1")

SE0270_RangeSet

SE0270_RangeSet is a standalone library that implements the Swift Evolution proposal SE-0270: Add Collection Operations on Noncontiguous Elements. You can use this package independently, or as part of the standard library preview package.

Functionality

SE0270_RangeSet provides operations on noncontiguous subranges of collections, such as subranges(where:) and moveSubranges(_:to:), as well as the supporting RangeSet type.

import SE0270_RangeSet

var numbers = [10, 12, -5, 14, -3, -9, 15]
let negatives = numbers.subranges(where: { $0 < 0 })
// numbers[negatives].count == 3

numbers.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:

.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:

.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

Contributions to this package and the standard library preview package are welcomed and encouraged!

GitHub

link
Stars: 10
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

Fix subscript setters
3 weeks ago

Bugfixes:

  • Adds a missing setter for DiscontinousSlice.subscript(bounds:)
  • Prevents out-of-bounds assignment when using the multiple-range setter for Collection.subscript(subranges:)

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics