Swift Algorithms 0.0.3
Additions
An exciting group of new algorithms, contributed by the community:
trimming(while:)returns a subsequence of a bidirectional collection with the matching elements removed from the start and end. (#4)min(ofCount:)andmax(ofCount:)find the smallest or largest elements in a collection. (#9, #77)windows(ofCount:)lets you iterate over all the overlapping subsequences of a particular length. (#20)striding(by:)iterates over every nth element of a sequence or collection. (#24)interspersed(with:)places a new element between every pair of elements in a sequence or collection. (#35)chunks(ofCount:)breaks a collection into subsequences of the given number of elements. (#54)suffix(while:)matches the standard library'sprefix(while:), by returning the suffix of all matching elements from a bidirectional collection. (#65)- Variations of
combinations(ofCount:)andpermutations(ofCount:)that take a range expression as a parameter, returning combinations and permutations of multiple lengths. (#51, #56)
Changes
- The
LazyChunkedtype now precomputes itsstartIndex, making performance more predictable when using the collection.
Fixes
randomSample(count:)no longer traps in rare circumstances.- Index calculations have been improved in a variety of collection wrappers.
- A variety of documentation improvements and corrections.