# Simpliest NSOrderedSet alternative on linux for a simple Swift-Script?

**URL:** <https://forums.swift.org/t/simpliest-nsorderedset-alternative-on-linux-for-a-simple-swift-script/57679>\
**Category:** Using Swift\
**Created:** [May 30, 2022, 2:47am UTC](https://forums.swift.org/t/simpliest-nsorderedset-alternative-on-linux-for-a-simple-swift-script/57679 "2022-05-30T02:47:49Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Nevin](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nevin/32/617_2.png) [@Nevin](https://forums.swift.org/u/Nevin)\
**Post date:** [May 30, 2022, 10:50pm UTC](https://forums.swift.org/t/simpliest-nsorderedset-alternative-on-linux-for-a-simple-swift-script/57679/5 "2022-05-30T22:50:21Z")

</div>

If you just need a one-time depublication of an array, you can write something like this:

> [@Algorithms.uniqued() is not ergonomic](https://forums.swift.org/t/algorithms-uniqued-is-not-ergonomic/53056/4):
>
> If you do want to maintain the order of the remaining elements, here’s an in-place implementation: extension RangeReplaceableCollection where Element: Hashable { mutating func removeDuplicates() { var alreadySeen: Set\<Element\> = [] removeAll { !alreadySeen.insert($0).inserted } } }

```swift
extension RangeReplaceableCollection where Element: Hashable {
  mutating func removeDuplicates() {
    var alreadySeen: Set<Element> = []
    removeAll { !alreadySeen.insert($0).inserted }
  }
}

```

---

_[View the full topic](https://forums.swift.org/t/simpliest-nsorderedset-alternative-on-linux-for-a-simple-swift-script/57679)._
