Blog

Removing duplicate elements from a Swift array

18 Dec, 2015

Today I had to remove duplicate items from an Array while maintaining the original order. I knew there was no standard uniq function in Swift so I Googled a bit and found some implementations on StackOverflow. I found some good implementations, but wasn’t completely satisfied with any of them. So of course I tried to see if I could make something myself that I would be satisfied with.

guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Eugen Martynov
Eugen Martynov
6 years ago

As already mentioned (sorry can not post on your blog by some unknown reason), usage of set instead of array for `seen` elements will be more performant

Explore related posts