import Collections
import ComposableArchitecture

/*
 Convenience methods that return an IdentifiedArrayOf<Element>
 from an array. This makes sure to de-duplicate the elements
 using OrderedSet.
 */
public extension Array where Element: Identifiable & Hashable {
    func deduplicated() -> [Element] {
        return Array(OrderedSet(self))
    }

    func deduplicatedIdentifiedArray() -> IdentifiedArrayOf<Element> {
        return IdentifiedArray(uniqueElements: Array(OrderedSet(self)))
    }
}
