Documentation ¶
Index ¶
- func StringInSlice(haystack []string, needle string) bool
- func Trim(origin, trimFrom []string) []string
- func TrimStable(origin, trimFrom []string) []string
- func TrimStableUnique(origin, trimFrom []string) []string
- func TrimUnique(origin, trimFrom []string) []string
- func UniqueStrings(strSlice []string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringInSlice ¶
StringInSlice determines if a needle is in a haystack of strings.
func Trim ¶
Trim returns the origin slice with all the elements from "trimFrom" removed.
The original order of the original elements may be altered.
NOTE: this function does not allocate extra memory: the input slice is altered in-place.
The returned slice is truncated in capacity to the number of unique elements.
func TrimStable ¶
TrimStable returns the origin slice with all the elements from "trimFrom" removed.
The original order of the original elements is maintained. Memory and CPU efficiency is about the same as Trim().
NOTE: this function does not allocate extra memory: the input slice is altered in-place.
The returned slice is truncated in capacity to the number of unique elements.
func TrimStableUnique ¶
TrimStableUnique combines UniqueStrings and Trim in a single iteration.
It returns the unique elements of the origin slice with all the elements from "trimFrom" removed.
NOTE: this function does not allocate extra memory: the input slice is altered in-place.
The returned slice is truncated in capacity to the number of unique elements.
Calling TrimUnique in combination is slighly more efficient than calling these functions separately (the longer the slices, the larger the savings).
func TrimUnique ¶
TrimUnique combines UniqueStrings and Trim in a single iteration.
It returns the unique elements of the origin slice with all the elements from "trimFrom" removed.
NOTE: this function does not allocate extra memory: the input slice is altered in-place.
The returned slice is truncated in capacity to the number of unique elements.
Calling TrimUnique in combination is slighly more efficient than calling these functions separately (the longer the slices, the larger the savings).
func UniqueStrings ¶
UniqueStrings returns the unique (unsorted) values of a slice.
NOTE: this function does not allocate extra memory: the input slice is altered in-place.
The returned slice is truncated in capacity to the number of unique elements.
Types ¶
This section is empty.