slicesx

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: BSD-3-Clause Imports: 1 Imported by: 10

Documentation

Overview

Package slicesx provides additional slice functions beyond those in the standard slices package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Move

func Move[E any](s []E, from, to int) []E

Move moves the element in the given slice at the given old position to the given new position and returns the resulting slice.

func Search[E any](slice []E, match func(e E) bool, startIndex ...int) int

Search returns the index of the item in the given slice that matches the target according to the given match function, using the given optional starting index to optimize the search by searching bidirectionally outward from given index. This is much faster when you have some idea about where the item might be. If no start index is given, it starts in the middle, which is a good default. It returns -1 if no item matching the match function is found.

func Swap

func Swap[E any](s []E, i, j int)

Swap swaps the elements at the given two indices in the given slice.

func ToAny

func ToAny[E any](s []E) []any

ToAny converts a slice of the given type to a []any slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳