slices

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 4 Imported by: 5

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