slice

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2018 License: Apache-2.0 Imports: 3 Imported by: 50

Documentation

Overview

Package slice provides utilities for mutating generic slices.

Index

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 Clone

func Clone(s interface{}) interface{}

Clone returns a shallow copy of the slice s.

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 New

func New(ty reflect.Type, len, cap int) reflect.Value

New returns a new addressable slice value of type ty.

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 added in v0.6.0

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

func SortValues(s []reflect.Value, elTy reflect.Type)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL