package
2.2.2
Repository: https://github.com/bobg/go-generics.git
Documentation: pkg.go.dev

# Functions

Accum accumulates the result of repeatedly applying a simple function to the elements of a slice.
Accumx is the extended form of [Accum].
Append is the same as Go's builtin append and is included for completeness.
BinarySearch searches for target in a sorted slice and returns the position where target is found, or the position where target would appear in the sort order; it also returns a bool saying whether the target is really found in the slice.
BinarySearchFunc works like BinarySearch, but uses a custom comparison function.
Clip removes unused capacity from the slice, returning s[:len(s):len(s)].
Clone returns a copy of the slice.
Combinations produces an iterator over all n-length combinations of distinct elements from s.
CombinationsWithReplacement produces an iterator over all n-length combinations of possibly repeated elements from s.
Compact replaces consecutive runs of equal elements with a single copy.
CompactFunc is like Compact but uses a comparison function.
Compare compares the elements of s1 and s2.
CompareFunc is like Compare but uses a comparison function on each pair of elements.
Contains reports whether v is present in s.
ContainsFunc reports whether at least one element e of s satisfies f(e).
Delete removes the elements s[i:j] from s, returning the modified slice.
Each runs a simple function on each item of a slice.
Eachx is the extended form of [Each].
Equal reports whether two slices are equal: the same length and all elements equal.
EqualFunc reports whether two slices are equal using a comparison function on each pair of elements.
Filter calls a simple predicate for each element of a slice, returning a slice of those elements for which the predicate returned true.
Filterx is the extended form of [Filter].
Get gets the idx'th element of s.
Group partitions the elements of a slice into groups.
Groupx is the extended form of [Group].
Grow increases the slice's capacity, if necessary, to guarantee space for another n elements.
Index returns the index of the first occurrence of v in s, or -1 if not present.
IndexFunc returns the first index i satisfying f(s[i]), or -1 if none do.
Insert inserts the given values at the idx'th location in s and returns the result.
IsSorted reports whether x is sorted in ascending order.
IsSortedFunc reports whether x is sorted in ascending order, with less as the comparison function.
KeyedSort sorts the given slice according to the ordering of the given keys, whose items must map 1:1 with the slice.
Map runs a simple function on each item of a slice, accumulating results in a new slice.
Mapx is the extended form of [Map].
Permutations produces an iterator over all permutations of s.
Prefix returns s up to but not including position idx.
Put puts a given value into the idx'th location in s.
RemoveN removes n items from s beginning at position idx and returns the result.
RemoveTo removes items from s beginning at position from and ending before position to.
Replace replaces the elements s[i:j] by the given v, and returns the modified slice.
ReplaceN replaces the n values of s beginning at position idx with the given values.
ReplaceTo replaces the values of s beginning at from and ending before to with the given values.
Reverse reverses a slice in place.
Rotate rotates a slice in place by n places to the right.
SliceN returns n elements of s beginning at position idx.
SliceTo returns the elements of s beginning at position from and ending before position to.
Sort sorts a slice of any ordered type in ascending order.
SortFunc sorts the slice x in ascending order as determined by the less function.
SortStableFunc sorts the slice x while keeping the original order of equal elements, using less to compare elements.
Suffix returns s excluding elements before position idx.