package utils

// UniqueUintSlice returns a new slice containing distinct values in the order of first appearance.
func UniqueUintSlice(values []uint) []uint {
	if len(values) == 0 {
		return nil
	}

	seen := make(map[uint]struct{}, len(values))
	result := make([]uint, 0, len(values))
	for _, v := range values {
		if _, ok := seen[v]; ok {
			continue
		}
		seen[v] = struct{}{}
		result = append(result, v)
	}
	return result
}

// MissingUintIDs returns the values present in expected but missing from actual.
func MissingUintIDs(expected, actual []uint) []uint {
	lookup := make(map[uint]struct{}, len(actual))
	for _, v := range actual {
		lookup[v] = struct{}{}
	}
	missing := make([]uint, 0)
	for _, v := range expected {
		if _, ok := lookup[v]; !ok {
			missing = append(missing, v)
		}
	}
	return missing
}
