Documentation
¶
Index ¶
- func AnyWithin[V comparable, S ~[]V](src S, others ...S) (present bool)
- func Append[V comparable, S ~[]V](src S, values ...V) (modified S)
- func Carve[V comparable, S ~[]V](src, start, end S) (before, middle, after S, found bool)
- func CarveString[V ~string](src, start, end V) (before, middle, after V, found bool)
- func Copy[V interface{}, S ~[]V](slice S) (copied S)
- func Cut[V comparable, S ~[]V](src, sep S) (before, after S, found bool)
- func DuplicateCounts[V comparable, S ~[]V](src S) (counts map[V]int)
- func Equal[V comparable, S ~[]V](src S, others ...S) (same bool)
- func IndexOf[V comparable, S ~[]V](slice S, value V) (index int)
- func IndexesOf[V comparable, S ~[]V](slice S, value V) (indexes []int)
- func Insert[V interface{}, S ~[]V](slice S, at int, values ...V) (modified S)
- func Merge[V comparable, S ~[]V](src S, others ...S) (modified S)
- func Pop[V interface{}, S ~[]V](slice S) (modified S, value V)
- func Present[V comparable](search V, others ...V) (present bool)
- func Prune[V comparable, S ~[]V](slice S, values ...V) (modified S)
- func Push[V interface{}, S ~[]V](slice S, values ...V) (modified S)
- func Remove[V interface{}, S ~[]V](slice S, at int) (modified S)
- func Retype[T interface{}](src []interface{}) (slice []T, ok bool)
- func Shift[V interface{}, S ~[]V](slice S, values ...V) (modified S)
- func StartsWith[V comparable, S ~[]V](src S, others ...S) (same bool)
- func ToCamels(list []string) (camel []string)
- func ToKebabs(list []string) (kebabs []string)
- func ToScreamingKebabs(list []string) (screamingKebabs []string)
- func ToScreamingSnakes(list []string) (screamingSnakes []string)
- func ToSnakes(list []string) (snakes []string)
- func Truncate[V interface{}, S ~[]V](slice S, length int) (truncated S)
- func Unique[V comparable, S ~[]V](src S) (unique S)
- func Unshift[V interface{}, S ~[]V](slice S) (modified S, value V)
- func Within[V comparable, S ~[]V](search V, others ...S) (present bool)
- type Stack
- func (s *Stack[V]) First() (item V, ok bool)
- func (s *Stack[V]) Get(idx int) (item V, ok bool)
- func (s *Stack[V]) Last() (item V, ok bool)
- func (s *Stack[V]) Len() (size int)
- func (s *Stack[V]) Pop() (item V, ok bool)
- func (s *Stack[V]) Push(item V)
- func (s *Stack[V]) Set(idx int, item V) (ok bool)
- func (s *Stack[V]) Shift(item V)
- func (s *Stack[V]) Unshift() (item V, ok bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyWithin ¶
func AnyWithin[V comparable, S ~[]V](src S, others ...S) (present bool)
AnyWithin returns true if any of the values in the source given are present in any of the other slices given
func Append ¶
func Append[V comparable, S ~[]V](src S, values ...V) (modified S)
Append returns a new slice appended with only values not within the src slice
func Carve ¶ added in v1.2.0
func Carve[V comparable, S ~[]V](src, start, end S) (before, middle, after S, found bool)
Carve finds the `start` and `end` markers in `src` and carves out the "before carve", "middle of start/end range" and "after carve" segments. If the `start` and `end` range is not `found` then the `before` will contain the entire `src` input
func CarveString ¶ added in v1.3.0
CarveString recasts the given ~string arguments to []rune slices, calls Carve and recasts the []rune slices returns values back to the original type
func Copy ¶
func Copy[V interface{}, S ~[]V](slice S) (copied S)
Copy creates a new slice (array) from the given slice
func Cut ¶ added in v1.1.0
func Cut[V comparable, S ~[]V](src, sep S) (before, after S, found bool)
Cut is the slices version of strings.Cut
func DuplicateCounts ¶
func DuplicateCounts[V comparable, S ~[]V](src S) (counts map[V]int)
DuplicateCounts returns a mapping of values and their respective counts, distinct values not included
func Equal ¶
func Equal[V comparable, S ~[]V](src S, others ...S) (same bool)
Equal returns true if all the slices given have the same values
func IndexOf ¶
func IndexOf[V comparable, S ~[]V](slice S, value V) (index int)
IndexOf returns the first index matching the value given
func IndexesOf ¶
func IndexesOf[V comparable, S ~[]V](slice S, value V) (indexes []int)
IndexesOf returns a list of all indexes matching the value given
func Insert ¶
func Insert[V interface{}, S ~[]V](slice S, at int, values ...V) (modified S)
Insert creates a new slice (array) from the given slice, with additional values inserted at the given index
func Merge ¶
func Merge[V comparable, S ~[]V](src S, others ...S) (modified S)
Merge returns a new slice with the new values found within others appended to the src slice
func Pop ¶
func Pop[V interface{}, S ~[]V](slice S) (modified S, value V)
Pop removes the last value from a Copy of the slice and returns it
func Present ¶
func Present[V comparable](search V, others ...V) (present bool)
Present returns true if the search value is present in any of the other values given
func Prune ¶
func Prune[V comparable, S ~[]V](slice S, values ...V) (modified S)
Prune removes all instances of the specified values from a copy of the given slice
func Push ¶
func Push[V interface{}, S ~[]V](slice S, values ...V) (modified S)
Push appends the given value to a new copy of the given slice
func Remove ¶
func Remove[V interface{}, S ~[]V](slice S, at int) (modified S)
Remove creates a new slice (array) from the given slice, with the specified index removed
func Shift ¶
func Shift[V interface{}, S ~[]V](slice S, values ...V) (modified S)
Shift prepends the given value to a new copy of the given slice
func StartsWith ¶
func StartsWith[V comparable, S ~[]V](src S, others ...S) (same bool)
StartsWith returns true if the other slices given start with the same values as the src
func ToScreamingKebabs ¶
func ToScreamingSnakes ¶
func Truncate ¶
func Truncate[V interface{}, S ~[]V](slice S, length int) (truncated S)
Truncate creates a new slice (array), of specified length, from the given slice
func Unique ¶
func Unique[V comparable, S ~[]V](src S) (unique S)
Unique returns a new slice with duplicate values omitted, maintaining order
func Unshift ¶
func Unshift[V interface{}, S ~[]V](slice S) (modified S, value V)
Unshift removes the first value from a Copy of the slice and returns it
func Within ¶
func Within[V comparable, S ~[]V](search V, others ...S) (present bool)
Within return true if the search value is present in any of the other slices of V given
Types ¶
type Stack ¶ added in v1.5.0
type Stack[V interface{}] struct {
// contains filtered or unexported fields
}
Stack is a concurrency-safe manager for a stack of generic items
func NewStack ¶ added in v1.5.0
func NewStack[V interface{}](items ...V) *Stack[V]
NewStack creates a new Stack instance
func (*Stack[V]) Push ¶ added in v1.5.0
func (s *Stack[V]) Push(item V)
Push appends the given item to the end of the Stack