slicesutil

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EqualUnsorted

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

EqualUnsorted reports whether two slices contain the same elements, regardless of order. Duplicates are accounted for: [1, 1, 2] is not equal to [1, 2, 2]. Returns true if both slices are empty.

Runs in O(n²) time, but the matched slice should be stack-allocated in most cases. A hash-based O(n) approach was considered, but for small slices the cost of populating a map outweighs the quadratic comparison cost. Additionally, maps with more than 8 elements are heap-allocated, which adds to the cost.

func Overlap

func Overlap[S ~[]E, E cmp.Ordered](s1, s2 S) bool

Overlap reports whether two sorted slices have at least one element in common. Both slices must be sorted in ascending order. Returns true if both slices are empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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