package
Version:
v0.0.0-...-a81b4a7
Opens a new window with list of versions in this module.
Published: Jun 26, 2017
License: Apache-2.0
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package slice implements operations on slices.
All operations act on slices of T. Use stencil to specialise to a type.
For example, in order to use a string version of this package, import it as
import (
str_slice "github.com/sridharv/stencil/std/slice/T/string"
)
and run stencil on the importing package.
Any returns true if fn is true for all elements of s
Any returns true if fn is true for any elements of s
func Index(s []T, e T) int
Index returns the first index of e in s
IndexFunc returns the index of the first element for which fn returns true.
If no such element exists it returns -1.
Pop removes the last element from a, returning an updating slice
Reverse reverses a in place.
func Sort(a []T, less func(a, b T) bool)
Sort sorts a using the comparison function less.
func SortStable(a []T, less func(a, b T) bool)
SortStable sorts a stably using the comparison function less.
func Cut(a []T, i, j int) []T
Cut removes all elements between i and j.
func Delete(a []T, i int) []T
Delete removes the ith element from a and returns the resulting slice.
func DeleteUnordered(a []T, i int) []T
DeleteUnordered removes the ith element in a, without preserving order. It can be faster that
Delete as it results in much fewer copies.
func Flatten(slices ...[]T) []T
Flatten returns a slice created by adding each element of each slice in slices
func Insert(a []T, v T, i int) []T
Insert inserts v in a at index i and returns the new slice
func InsertSlice(a []T, v []T, i int) []T
InsertSlice inserts v into a at index i and returns the new slice
func Push(a []T, v T) []T
Push pushes v on to the end of a, returning an updated slice.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.