slices

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MulanPSL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append added in v1.8.0

func Append[TYPE any](slice []TYPE, values ...TYPE) (newSlice []TYPE)

后面追加

func Copy added in v1.7.4

func Copy[TYPE any](slice []TYPE) (newSlice []TYPE)

深拷贝出一个slice

func Cut

func Cut[TYPE comparable](slice []TYPE, from, length int) (newSlice []TYPE)

slice中移除from开始到length长度的数据,from和length错误会产生panic

func Dequeue

func Dequeue[TYPE any](slice []byte) (newSlice []byte, value TYPE, ok bool)

slice后面追加value

func DequeueBytes added in v1.8.0

func DequeueBytes(slice []byte, length int) (newSlice []byte, cuted []byte, ok bool)

slice前面取出片段

func DequeueString

func DequeueString(slice []byte, length int) (newSlice []byte, str string, ok bool)

slice前面取出字符串

func Enqueue

func Enqueue[TYPE any](slice []byte, value TYPE) (newSlice []byte)

将values插入到slice的from位置. 若from位置不合法将会产生panic

func Index

func Index[TYPE comparable](slice []TYPE, value TYPE) int

返回value在Index中出现的位置,不存在返回-1

func Inserts

func Inserts[TYPE any](slice []TYPE, from int, values ...TYPE) (newSlice []TYPE)

将values插入到slice的from位置,form及以后依次后移. 若from位置不合法将会产生panic

func Remove

func Remove[TYPE comparable](slice []TYPE, value TYPE) (newSlice []TYPE)

从slice中删除所有value

func Sort

func Sort[TYPE comparable](slice []TYPE, swap func(first, last TYPE) bool) (newSlice []TYPE)

根据swap快速度排序,若swap回调函数的front应该在back后面返回true.

func Unite added in v1.8.0

func Unite[TYPE comparable](slice1 []TYPE, slice2 []TYPE) (unite []TYPE)

返回两个slice的交集

Types

This section is empty.

Jump to

Keyboard shortcuts

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