cockroach: Index | Files

package unique

import ""


Package Files


func UniquifyAcrossSlices Uses

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 Uses

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.

Package unique imports 3 packages (graph) and is imported by 7 packages. Updated 2020-05-16. Refresh now. Tools for package owners.