Skip to content

wltrup/CollectionDuplicateRemoval

Repository files navigation

CollectionDuplicateRemoval

Xcode Swift GitHub tag (latest SemVer) GitHub

What

CollectionDuplicateRemoval is a Swift Package Manager package for iOS/tvOS (10.0 and above), watchOS (4.0 and above), and macOS (10.14 and above), under Swift 5.0 and above, adding protocol extensions to Collection in order to define a function that returns an array of the elements of the collection, with duplicates removed.

public extension Collection where Element: Equatable {

    /// O(n^2) in the worst case.
    func duplicatesRemoved() -> [Element]

}

public extension Collection where Element: Equatable & Comparable {

    /// O(n.log(n)) in the worst case.
    func duplicatesRemoved() -> [Element]

}

public extension Collection where Element: Hashable {

    /// O(n) in the worst case, if the set operations
    /// contains(:) and insert(:) are O(1).
    func duplicatesRemoved() -> [Element]

}

Installation

CollectionDuplicateRemoval is provided only as a Swift Package Manager package, because I'm moving away from CocoaPods and Carthage, and can be easily installed directly from Xcode.

License

CollectionDuplicateRemoval is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages