slices

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package slices provides useful functions with slices of any type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[S ~[]E, E comparable](s S, e E) bool

Contains returns true if the given slices s contains k.

func Dedup

func Dedup[S ~[]E, E constraints.Ordered](s S) S

Dedup returns a sorted slice with duplicate entries removed.

func Diff

func Diff[S ~[]E, E comparable](s1, s2 S) S

Diff returns a slice of elements are in s1 but not in s2.

func Equal

func Equal[S ~[]E, E comparable](l, r S) bool

Equal returns true if the slices are the same.

func Intersection

func Intersection[S ~[]E, E comparable](s1, s2 S) S

Intersection returns a slice of elements that are both in s1 and s2. Order matters, the elements from s1 are compared to s2, so the resultant slice will be a subset of s1. If s1 has duplicates entries that intersect, they will be in the result.

func Last

func Last[S ~[]E, E any](s S) E

Last returns the last element of the slice.

func Merge

func Merge[S ~[]E, E comparable](l, r S) S

Merge returns the result of the merged slices.

func Pretty

func Pretty(s []string) string

Pretty prints the slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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