slicepkg

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

slice

切片反转、包含判断等基础操作,包含泛型辅助。

基础用法

ok := slicepkg.Contains([]string{"a", "b"}, "a")

注意事项

大切片高频查找可改用 map,避免线性扫描造成性能问题。

验证

go test ./slice

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](s []T, v T) bool

Contains 检查元素是否存在于切片中

func InStringSlice deprecated

func InStringSlice(s []string, dest string) bool

Deprecated: 使用 Contains 替代

func Reverse deprecated

func Reverse(slice interface{})

Deprecated: 使用 ReverseSlice 替代。 注意:Reverse 使用 reflect,性能较差且缺乏编译期类型检查。

func ReverseSlice

func ReverseSlice[T any](s []T)

ReverseSlice 原地反转切片

Types

This section is empty.

Jump to

Keyboard shortcuts

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