SoXX
802764092e
As mentioned in Issue #11, the folder structure got an overall as some file names Co-authored-by: Fenpaws <soxx@fenpa.ws> Reviewed-on: anthrove/e621-to-graph#14 Reviewed-by: Lennard Brinkhaus <lennard.brinkhaus@noreply.localhost> Co-authored-by: SoXX <fenpaws@noreply.localhost> Co-committed-by: SoXX <fenpaws@noreply.localhost>
28 lines
731 B
Go
28 lines
731 B
Go
package util
|
|
|
|
// UniqueNonEmptyElementsOf returns a new slice containing unique non-empty elements from the input slice.
|
|
// It removes duplicate elements and empty strings while preserving the order of appearance.
|
|
func UniqueNonEmptyElementsOf(s []string) []string {
|
|
// Create a map to store unique elements
|
|
unique := make(map[string]bool)
|
|
|
|
// Create a new slice to store the unique non-empty elements
|
|
us := make([]string, 0, len(s))
|
|
|
|
for _, elem := range s {
|
|
// Skip empty strings
|
|
if len(elem) == 0 {
|
|
continue
|
|
}
|
|
|
|
// Check if the element is already in the unique map
|
|
if !unique[elem] {
|
|
// Add the element to the unique map and the new slice
|
|
unique[elem] = true
|
|
us = append(us, elem)
|
|
}
|
|
}
|
|
|
|
return us
|
|
}
|