Last active
August 29, 2015 14:12
-
-
Save WeZZard/51c3fe66d639c885340a to your computer and use it in GitHub Desktop.
Remove duplicate items in a ExtensibleCollectionType conformed collection object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func removeDuplicates<C: ExtensibleCollectionType where C.Generator.Element : Equatable>(aCollection: C) -> C { | |
var container = C() | |
for element in aCollection { | |
if !contains(container, element) { | |
container.append(element) | |
} | |
} | |
return container | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment