mirror of
https://github.com/apple/swift-algorithms
synced 2026-11-22 04:10:39 +00:00
* 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>