slices

package
v2.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 4 Imported by: 5 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package slices has several utilities for operating on slices given Go's lack of generic types. Many functions take an argument of type func(l, r T) bool, that's expected to compute l < r where T is T in []T, the type of the given slice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterInPlace

func FilterInPlace(sl interface{}, f interface{})

sl []T, f is func(*T) bool.

func FromMapElems

func FromMapElems(m interface{}) interface{}

Returns all the elements []T, from m where m is map[K]T.

func FromMapKeys

func FromMapKeys(m interface{}) interface{}

Returns all the elements []K, from m where m is map[K]T.

func HeapInterface

func HeapInterface(sl interface{}, less interface{}) heap.Interface

Returns a "container/heap".Interface for the provided slice.

func MakeInto

func MakeInto(ptrTo interface{}, from interface{})

Makes and sets a slice at *ptrTo, and type asserts all the elements from from to it.

func Map

func Map(f, input interface{}) interface{}

f: (T)T, input: []T, outout: []T

func Sort

func Sort(sl interface{}, less interface{}) interface{}

Sorts the slice in place. Returns sl for convenience.

func ToEmptyInterface

func ToEmptyInterface(slice interface{}) (ret []interface{})

Returns a copy of all the elements of slice []T as a slice of interface{}.

Types

type MapItem

type MapItem struct {
	Key, Elem interface{}
}

func FromMap

func FromMap(m interface{}) (slice []MapItem)

Creates a []struct{Key K; Value V} for map[K]V.

Jump to

Keyboard shortcuts

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