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 extension Sequence where Element : Hashable { | |
| /// Returns an array containing the unique elements from the sequence. | |
| /// | |
| /// - Parameter keepLast: A boolean value indicating whether to keep the last occurrence of each duplicated element. | |
| /// If `true`, the last occurrence is kept. If `false`, the first occurrence is kept. The default value is `false`. | |
| /// - Returns: An array containing the unique elements from the sequence based on the `keepLast` behavior. | |
| /// - Complexity: O(n), where `n` is the length of the sequence. | |
| func unique(keepLast: Bool = false) -> [Element] { | |
| guard !keepLast else { return reversed().unique(keepLast: false).reversed() } |
OlderNewer