Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortedUnique ¶
func SortedUnique[S ~[]T, T constraints.Ordered](s S) S
SortedUnique sorts and dedup the input slice in place. It uses the < operator to compare the elements in the slice and thus requires the elements to satisfies contraints.Ordered.
func SortedUniqueFunc ¶
SortedUniqueFunc is like SortedUnique but allows the user to specify custom functions for ordering (less function) and comparing (eq function) the elements in the slice. This is useful in all the cases where SortedUnique cannot be used: - for types that do not satisfy constraints.Ordered (e.g: composite types) - when the user wants to customize how elements are compared (e.g: user wants to enforce reverse ordering)
func Unique ¶
func Unique[S ~[]T, T comparable](s S) S
Unique deduplicates the elements in the input slice, preserving their ordering and modifying the slice in place. Unique relies on a map to find multiple occurrences of the same elements. For slices with a size less than 192 elements, a simpler O(N^2) search algorithm that does not allocate memory is used instead. Limit of 192 has been experimentally derived (look at BenchmarkUnique for more information).
Types ¶
This section is empty.