slices

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package slices provides helpful functions for slices

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chunk

func Chunk[T any](slice []T, size int) [][]T

Chunk returns a slice of slices of size Each of size specified - last may be smaller Panics when size <= 0

func Contains

func Contains[T comparable](slice []T, value T) bool

Contains returns true if value is found Empty slice always returns false

func ContainsCount

func ContainsCount[T comparable](slice []T, value T) int

ContainsCount gives back the count of value findings

func EqualsIgnoreOrder

func EqualsIgnoreOrder[ComparableSlice ~[]Type, Type comparable](s1 ComparableSlice, s2 ComparableSlice) bool

EqualsIgnoreOrder compares two splices ignoring the order of elements It returns true if both slices contain the same elements (and same frequency of same elements), regardless of order

func IndexOf

func IndexOf[T comparable](slice []T, value T) int

IndexOf returns index of first match. Similar to strings.Index Empty slice / no finding returns -1

func IndexOfAll

func IndexOfAll[T comparable](slice []T, value T) []int

IndexOfAll returns all positions of value findings

func Reverse

func Reverse[T any](slice []T)

Reverse flips the contents of the slice

func Unique

func Unique[T comparable](slice []T) []T

Unique returns a new slice containing only the unique values from slice (deduplication)

Types

This section is empty.

Jump to

Keyboard shortcuts

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