- Restructure the project README, moving the list of guides into a
README in the `Guides` directory
- Curate the `keyed(by:)` and `grouped(by:)` methods
* Add Grouped and Keyed
* Add `Key` to `combine` closure
* Split `keyed(by:)` into two overloads
* Rename uniquingKeysWith → resolvingConflictsWith
* Keep latest instead of throwing on collision
* Add `partitioned(_:)`
`partitioned(_:)` works like `filter(_:)`, but also returns the excluded elements by returning a tuple of two `Array`s
* For collections with fewer than 8 elements, use the `Sequence`-based implementation
This constant was determined using benchmarking. More information: https://github.com/apple/swift-algorithms/pull/152#issuecomment-887130149
* Remove check for collections fewer than 8 elements
* Make `_partitioned` `internal`
* Prefer `Array` over `ContiguousArray`
* Document `partitioned(_:)` on `Collection`
* Remove `partitioned(upTo:)`
* Remove `_tupleMap`
* Remove `_partitioned` and use it inline (since it’s no longer used by the `Collection` implementation
* Remove unnecessary conversation of `Array` to `Array`
* Correct indentation
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
* Consistent syntax
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
* Add an external `by:` label to `partitioned`
* Add labels to returned tuple `falseElements`, `trueElements`
* Correct function signature
* Rename `belongsInSecondCollection` parameter name to simply `predicate`
The parameter name was potentially confusing. Unlike the other `partition` functions, this function can rely on its named tuple to clarify its behavior.
* Update copyright information
Co-authored-by: Nate Cook <natecook@apple.com>
* Update documentation
Co-authored-by: Nate Cook <natecook@apple.com>
* Update comment
* Add a precondition to ensure that the count matches up with the number of actual elements found while iterating
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
Co-authored-by: Nate Cook <natecook@apple.com>
* Rename types to include a Sequence or Collection suffix, and clean up some guides
* Various refactors
* Replace `validateIndexTraversals` test method with `IndexValidator` type
* Add LazySequenceProtocol to StridingSequence, StridingCollection
* Update the Numerics dependency to 1.0
* Set `IndexedCollection.Indices` to `Base.Indices`
* Remove deprecations
* Update the changelog/README for the 1.0.0 release
* Fix compiler error on Linux
* Rename `WindowsCollection` to `WindowsOfCountCollection`
* Add function to find MIN and MAX in one pass
Add a method extending sequences that finds both the minimal and maximal elements of the receiver in a single pass, based off a given ordering predicate. Add an overload that defaults the comparison predicate to the standard less-than operator.
* Add uniquePermutations as wrapper for nextPermutation
* Implement uniquePermutations(ofCount:) variants
* Simplify UniquePermutations.Iterator.next()
* Add tests for uniquePermutations
* Move to a predicate-based uniquePermutations
* Add method documentation
* Convert to Hashable-based uniquing instead of Comparable
* Streamline tests, cover uniqueness
* Use optional count to collapse no-count method
* Update API documentation
* Remove leftover version of nextPermutation()
* Remove Hashable requirement from the UniquePermutations type
* Update documentation
* Apply Tim's great revisions
Co-authored-by: Tim Vermeulen <tvermeulen@apple.com>
* Add lazy conformance to UniquePermutations
Co-authored-by: Tim Vermeulen <tvermeulen@apple.com>
`split(maxSplits:omittingEmptySubsequences:whereSeparator:)`
and
`split(separator:maxSplits:omittingEmptySubsequences:)`
now operate lazily when called on `LazySequenceProtocol`- or
`LazyCollectionProtocol`-conforming values. In the latter case,
no additional storage is allocated on the heap.
This renames sortedPrefix to min(count:), adds max(count:),
and moves both methods down to Sequence.
In order to still provide the optimization when `count` is close to
a collection's length, we include a Collection-specific overload of
all methods. These won't be accessed when in a Sequence-generic context,
but it's the best we can do without adding these methods as protocol
requirements.
* Rename `chained(with:)` to `chain(_:_:)`
This follows a forum discussion about the `chained(with:)` name.
The old names are preserved as deprecated symbols.
* Remove conditional lazy conformance from `Chain2`