import Foundation
// powered by http://stackoverflow.com/questions/40579554/how-to-display-unique-elements-of-an-array-using-swift
-// swiftlint:disable syntactic_sugar
extension Sequence where Iterator.Element: Hashable {
func unique() -> [Iterator.Element] {
- var alreadyAdded = Array<Iterator.Element>()
+ var alreadyAdded = Set<Iterator.Element>()
return filter {
if alreadyAdded.contains($0) { return false }
- alreadyAdded.append($0)
+ alreadyAdded.insert($0)
return true
}
}
}
-// swiftlint:enable syntactic_sugar
extension Array {
func appended(_ elem: () -> Element) -> Array {