unique

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UniquifyAcrossSlices

func UniquifyAcrossSlices(
	left interface{},
	right interface{},
	cmpFunc func(l, r int) int,
	setLeft func(i, j int),
	setRight func(i, j int),
) (leftLen, rightLen int)

UniquifyAcrossSlices removes elements from both slices that are duplicated across both of the slices. For example, inputs [1,2,3], [2,3,4] would remove 2 and 3 from both lists. It assumes that both slices are pre-sorted using the same comparison metric as cmpFunc provides, and also already free of duplicates internally. It returns the slices, which will have also been sorted as a side effect. cmpFunc compares the lth index of left to the rth index of right. It must return less than 0 if the left element is less than the right element, 0 if equal, and greater than 0 otherwise. setLeft sets the ith index of left to the jth index of left. setRight sets the ith index of right to the jth index of right. The function returns the new lengths of both input slices, whose elements will have been mutated, but whose lengths must be set the new lengths by the caller.

func UniquifyByteSlices

func UniquifyByteSlices(slices [][]byte) [][]byte

UniquifyByteSlices takes as input a slice of slices of bytes, and deduplicates them using a sort and unique. The output will not contain any duplicates but it will be sorted.

Types

This section is empty.

Jump to

Keyboard shortcuts

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