9 Commits
Author SHA1 Message Date
Nate Cook 66ae806bbe Enable CI format check (#253)
* Incorporate swift-format formatting fixes
* Resolve linting issues
* Doc edits, mostly to fix linter-identified issues
* Early exit improvements
* Indentation fixes
* Line lengths to 80 maximum
* Implement case binding rule, plus argument line break improvements
* Implement NoForceUnwrap rule
* Format the tests, as well
* Stop masquerading as XCTest
2025-03-05 09:11:17 -06:00
Taras Tsugrii dd4e0e70ff [minmax] Do nothing for empty suffix/prefix. (#202)
It's a semantical noop but slightly more efficient for the case when max/min is requested for an empty Collection.
2023-10-31 11:03:19 -05:00
Matt Dickoff aa6349dea0 Corrects variable name in max functions to better reflect usage
The variable smallestThree should really be named largestThree. Looks
like this was originally a copy paste error from the min documentation.
2022-12-01 11:37:32 -06:00
Matt Zanchelli 19c1d00177 Remove the last element before determining the insertion index (#173)
This could result in fewer comparisons.

Additionally, it ensures that the insertion index is valid for insertion. The `removeLast()` documentation states:
> Calling this method may invalidate all saved indices of this collection. Do not rely on a previously stored index value after altering a collection with any operation that can change its length.
2021-12-04 00:25:02 -06:00
Tim Vermeulen c5ea9e3e36 Prepare for Swift Algorithms 1.0 (#167)
* 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`
2021-09-09 01:01:36 +02:00
Nate Cook f9f3a5ccc4 Minor revisions to minAndMax() (#143)
* Settle on 2-way approach (s/o to @NevinBR)
* Add tests for predicate usage and stability
* Update the return value semantics
2021-05-13 12:31:13 -05:00
Daryle Walker 4038b5da40 Simultaneous Minimum and Maximum Evaluation (#90)
* 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.
2021-05-12 16:11:33 -05:00
Matt Zanchelli 220649e999 Correct typos (#113)
largets -> largest
2021-03-25 00:05:49 -07:00
Nate Cook bd64bef3d2 Rename sortedPrefix methods (#77)
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.
2021-02-26 13:57:55 -06:00