Documentation ¶
Overview ¶
Package slice provides utilities for mutating generic slices.
Index ¶
- func Append(s interface{}, v interface{})
- func Bytes(ptr unsafe.Pointer, size uint64) []byte
- func Cast(sli interface{}, to reflect.Type) interface{}
- func Clone(s interface{}) interface{}
- func InsertBefore(s interface{}, i int, v interface{})
- func New(ty reflect.Type, len, cap int) reflect.Value
- func Remove(s, v interface{})
- func RemoveAt(s interface{}, i, n int)
- func Replace(s interface{}, first, count int, with interface{})
- func Reverse(s interface{})
- func Sort(s interface{})
- func SortValues(s []reflect.Value, elTy reflect.Type)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
func Append(s interface{}, v interface{})
Append appends s with v. s must be a pointer to a slice. v can be a slice or a single element.
func Cast ¶
Cast performs an unsafe cast of the slice at sli to the given slice type. Cast uses internal casting which may completely break in future releases of the Golang language / compiler.
func InsertBefore ¶
func InsertBefore(s interface{}, i int, v interface{})
InsertBefore inserts v before the i'th element in s. s must be a pointer to a slice. v can be a slice or a single element.
func Remove ¶
func Remove(s, v interface{})
Remove removes all occurances of v from the slice s. s must be a pointer to a slice.
func RemoveAt ¶
func RemoveAt(s interface{}, i, n int)
RemoveAt removes n elements from s starting at i. s must be a pointer to a slice.
func Replace ¶
func Replace(s interface{}, first, count int, with interface{})
Replace replaces count elements of s starting from first with with. s must be a pointer to a slice.
func Reverse ¶
func Reverse(s interface{})
Reverse swaps the order of elements in the slice so that the first become the last, and so on.
func Sort ¶
func Sort(s interface{})
Sort sorts the elements of the slice s into ascending order. Numbers are sorted numerically. Booleans are sorted with false before true. Everything else is sorted lexicographically by first converting to string with Sprintf.
func SortValues ¶
SortValues sorts the reflect.Values in the slice s into ascending order. All the elements of e need to be of the type elTy. Numbers are sorted numerically. Booleans are sorted with false before true. Everything else is sorted lexicographically by first converting to string with Sprintf.
Types ¶
This section is empty.