Documentation ¶
Index ¶
- func Copy[S ~[]E, E any](source S, more ...E) S
- func InsertAt[S ~[]E, E any](slice S, index int, value E) S
- func InsertRunAt[S ~[]E, E any](slice S, index, count int) S
- func InsertSliceAt[S ~[]E, E any](slice S, subslice S, index int) S
- func IsOneOf[E comparable](v E, slice ...E) bool
- func Keys[K comparable, V any](m map[K]V) (results []K)
- func MakeRun[S ~[]E, E any](element E, count int) S
- func MulDiv[T constraints.Integer](value, numerator, denominator T) T
- func MulDivRoundUp[T constraints.Integer](value, numerator, denominator T) T
- func RemoveSpan[S ~[]E, E any](slice S, startIndex, count int) S
- func RemoveSpanInSitu[S ~[]E, E any](slice S, startIndex, count int) S
- func Reverse[S ~[]E, E any](s S) S
- func ReverseInSitu[S ~[]E, E any](s S) S
- func SortedKeys[K ~string, V any](m map[K]V) (results []K)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
func Copy[S ~[]E, E any](source S, more ...E) S
creates a copy of the incoming slice, optionally with additional items appended
func InsertAt ¶
inserts the given item at the specified index (negative indexes are from the end of the slice) note: reuses the caller's slice when possible (does not guarantee a copy) warn: panics if you are OOB
func InsertRunAt ¶
inserts a series of copies of the specified element at index warn: if index is out of range, go will panic
func InsertSliceAt ¶
inserts a series of copies of the specified element at index warn: if index is out of range, will panic
func IsOneOf ¶
func IsOneOf[E comparable](v E, slice ...E) bool
returns true if the given value is in the slice (handy for inline checks)
func Keys ¶
func Keys[K comparable, V any](m map[K]V) (results []K)
returns the keys from a map (in unpredictable order)
func MakeRun ¶
returns a slice that is a simple run of the given element warn: if count is negative, go will panic
func MulDiv ¶
func MulDiv[T constraints.Integer](value, numerator, denominator T) T
multiply two numbers and divide by a third of the same type (often useful for constraints.Integereger math)
func MulDivRoundUp ¶
func MulDivRoundUp[T constraints.Integer](value, numerator, denominator T) T
multiply two numbers and divide by a third of the same type, rounding up
func RemoveSpan ¶
creates a new slice sans the given sub-span
func RemoveSpanInSitu ¶
removes the specified subset from the span (overwrites the slice memory)
func Reverse ¶
func Reverse[S ~[]E, E any](s S) S
returns the reverse of the input slice (the output is separate from the input)
func SortedKeys ¶
returns the keys from a map (in sorted order)
Types ¶
This section is empty.