mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
21 lines
509 B
Go
21 lines
509 B
Go
package obiutils
|
|
|
|
// Unique returns a new slice containing only unique values from the input slice.
|
|
// The order of elements in the output slice is not guaranteed to match the input order.
|
|
//
|
|
// Parameters:
|
|
// - slice: The input slice containing potentially duplicate values
|
|
//
|
|
// Returns:
|
|
// - A new slice containing only unique values
|
|
func Unique[T comparable](slice []T) []T {
|
|
// Create a map to track unique values
|
|
seen := Set[T]{}
|
|
|
|
for _, v := range slice {
|
|
seen.Add(v)
|
|
}
|
|
|
|
return seen.Members()
|
|
}
|