{"id":13461790,"url":"https://github.com/apple/swift-algorithms","last_synced_at":"2025-05-15T00:03:43.642Z","repository":{"id":37207043,"uuid":"300135838","full_name":"apple/swift-algorithms","owner":"apple","description":"Commonly used sequence and collection algorithms for Swift","archived":false,"fork":false,"pushed_at":"2025-03-05T15:42:18.000Z","size":742,"stargazers_count":6134,"open_issues_count":55,"forks_count":446,"subscribers_count":243,"default_branch":"main","last_synced_at":"2025-05-06T23:36:52.675Z","etag":null,"topics":["algorithm","iterator","itertools"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apple.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-01T04:00:52.000Z","updated_at":"2025-05-05T02:07:45.000Z","dependencies_parsed_at":"2024-06-18T11:16:12.633Z","dependency_job_id":"074acc0b-7c69-4c9e-944a-4abd0b757dfc","html_url":"https://github.com/apple/swift-algorithms","commit_stats":{"total_commits":164,"total_committers":45,"mean_commits":"3.6444444444444444","dds":0.7987804878048781,"last_synced_commit":"34eec0dd27ba4b539fe01e61fac07c9227c65a63"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-algorithms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-algorithms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-algorithms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apple%2Fswift-algorithms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apple","download_url":"https://codeload.github.com/apple/swift-algorithms/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252873951,"owners_count":21817708,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","iterator","itertools"],"created_at":"2024-07-31T11:00:57.660Z","updated_at":"2025-05-07T11:50:15.158Z","avatar_url":"https://github.com/apple.png","language":"Swift","readme":"# Swift Algorithms\n\n**Swift Algorithms** is an open-source package of sequence and collection algorithms, along with their related types.\n\n## Overview\n\nThe Algorithms package provides a variety of sequence and collection operations, letting you cycle over a collection's elements, find combinations and permutations, create a random sample, and more.\n\nFor example, the package includes a group of \"chunking\" methods, each of which breaks a collection into consecutive subsequences. One version tests adjacent elements to find the breaking point between chunks — you can use it to quickly separate an array into ascending runs:\n\n```swift\nlet numbers = [10, 20, 30, 10, 40, 40, 10, 20]\nlet chunks = numbers.chunked(by: { $0 \u003c= $1 })\n// [[10, 20, 30], [10, 40, 40], [10, 20]]\n```\n\nAnother version looks for a change in the transformation of each successive value. You can use that to separate a list of names into groups by the first character:\n\n```swift\nlet names = [\"Cassie\", \"Chloe\", \"Jasmine\", \"Jordan\", \"Taylor\"]\nlet chunks = names.chunked(on: \\.first)\n// [[\"Cassie\", \"Chloe\"], [\"Jasmine\", \"Jordan\"], [\"Taylor\"]]\n```\n\nExplore more chunking methods and the remainder of the `Algorithms` package in the links below.\n\n## Documentation\n\nFor API documentation, see the library's official documentation in Xcode or on the Web.\n\n- [API documentation][docs]\n- [Swift.org announcement][announcement]\n- [API Proposals/Guides][guides]\n\n## Adding Swift Algorithms as a Dependency\n\nTo use the `Algorithms` library in a SwiftPM project, \nadd the following line to the dependencies in your `Package.swift` file:\n\n```swift\n.package(url: \"https://github.com/apple/swift-algorithms\", from: \"1.2.0\"),\n```\n\nInclude `\"Algorithms\"` as a dependency for your executable target:\n\n```swift\n.target(name: \"\u003ctarget\u003e\", dependencies: [\n    .product(name: \"Algorithms\", package: \"swift-algorithms\"),\n]),\n```\n\nFinally, add `import Algorithms` to your source code.\n\n## Source Stability\n\nThe Swift Algorithms package is source stable; version numbers follow [Semantic Versioning](https://semver.org/). Source breaking changes to public API can only land in a new major version.\n\nThe public API of the `swift-algorithms` package consists of non-underscored declarations that are marked `public` in the `Algorithms` module. Interfaces that aren't part of the public API may continue to change in any release, including patch releases.\n\nFuture minor versions of the package may introduce changes to these rules as needed.\n\nWe'd like this package to quickly embrace Swift language and toolchain improvements that are relevant to its mandate. Accordingly, from time to time, we expect that new versions of this package will require clients to upgrade to a more recent Swift toolchain release. Requiring a new Swift release will only require a minor version bump.\n\n[docs]: https://swiftpackageindex.com/apple/swift-algorithms/documentation/algorithms\n[announcement]: https://swift.org/blog/swift-algorithms/\n[guides]: https://github.com/apple/swift-algorithms/tree/main/Guides\n","funding_links":[],"categories":["Swift","HarmonyOS","apple-swift"],"sub_categories":["Windows Manager"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapple%2Fswift-algorithms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapple%2Fswift-algorithms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapple%2Fswift-algorithms/lists"}