slice

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 1 Imported by: 0

README

slice

Generic slices utils

Functions

RemoveDuplicates[S ~[]E, E comparable](s S) S
RemoveDuplicatesFunc[S ~[]E, E any](s S, equal func(a, b E) bool) S
ContainsDuplicates[S ~[]E, E comparable](s S) bool
ContainsDuplicatesFunc[S ~[]E, E any](s S, equal func(a, b E) bool) bool

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsDuplicates added in v0.2.0

func ContainsDuplicates[S ~[]E, E comparable](s S) bool

ContainsDuplicatesFunc returns true if slice contains equal elements. Equality calculated using an equality function.

func ContainsDuplicatesFunc added in v0.2.0

func ContainsDuplicatesFunc[S ~[]E, E any](s S, equal func(a, b E) bool) bool

ContainsDuplicatesFunc is like ContainsDuplicates but uses an equality function to compare elements.

func GetDuplicatesIndexes added in v0.3.0

func GetDuplicatesIndexes[S ~[]E, E comparable](s S) map[int][]int

GetDuplicatesIndexes returns duplicates indexes for every element of a slice.

func GetDuplicatesIndexesFunc added in v0.3.0

func GetDuplicatesIndexesFunc[S ~[]E, E any](s S, equal func(a, b E) bool) map[int][]int

GetDuplicatesIndexesFunc is like GetDuplicatesIndexes but uses an equality function to compare elements.

func RemoveDuplicates

func RemoveDuplicates[S ~[]E, E comparable](s S) S

RemoveDuplicates removes duplicates from slice of comparables. RemoveDuplicates modifies the contents of the slice s and returns the modified slice with truncated capacity.

func RemoveDuplicatesFunc

func RemoveDuplicatesFunc[S ~[]E, E any](s S, equal func(a, b E) bool) S

RemoveDuplicatesFunc is like RemoveDuplicates but uses an equality function to compare elements.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL