array

package
v0.0.0-...-8584990 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPtr

func CheckPtr(i any) bool

func Clear

func Clear[K KEYS, V VALUES](arr Arrays[K, V])

func Delete

func Delete[K KEYS, V VALUES](arr Arrays[K, V], key K) (value V)

func Deletes

func Deletes[K KEYS, V VALUES](arr Arrays[K, V], delKeys []K) map[K]V

func Exist

func Exist[K KEYS, V VALUES](arr Arrays[K, V], key K) (ok bool)

func First

func First[K KEYS, V VALUES](arr Arrays[K, V]) (key K, value V)

func Get

func Get[K KEYS, V VALUES](arr Arrays[K, V], key K) (value V)

func GetKey

func GetKey[K KEYS, V VALUES](arr Arrays[K, V], item int) (key K)

返回数组键切片对应下标的键

func GetKeys

func GetKeys[K KEYS, V VALUES](arr Arrays[K, V]) []K

返回数组键切片副本

func GetTypeString

func GetTypeString(i any) string

func GetValue

func GetValue[K KEYS, V VALUES](arr Arrays[K, V], item int) (value V)

返回数组值切片对应下标的值

func GetValues

func GetValues[K KEYS, V VALUES](arr Arrays[K, V]) []V

返回数组值切片副本

func Gets

func Gets[K KEYS, V VALUES](arr Arrays[K, V], keys []K) map[K]V

func Last

func Last[K KEYS, V VALUES](arr Arrays[K, V]) (key K, value V)

func Maps

func Maps[K KEYS, V VALUES](arr Arrays[K, V]) map[K]V

func Merges

func Merges[K KEYS, V VALUES](arrs ...Arrays[K, V])

合并数组将会把第一组之后的数组内容全部完整的复制到第一组内;相同键名的将以最后一个为准

func Push

func Push[K KEYS, V VALUES](arr Arrays[K, V], key K, value V) (V, bool)

func Set

func Set[K KEYS, V VALUES](arr Arrays[K, V], key K, value V) (ok bool)

func Sets

func Sets[K KEYS, V VALUES](arr Arrays[K, V], data map[K]V) map[K]V

Types

type Arrays

type Arrays[K KEYS, V VALUES] interface {
	Copy(Arrays[K, V])
	Len() int
	Swap(int, int)
	Init(map[K]V)
	// 后面的方法必须重写
	New() Arrays[K, V]
	Less(int, int) bool
	// contains filtered or unexported methods
}

func Copy

func Copy[K KEYS, V VALUES](arr Arrays[K, V]) Arrays[K, V]

func Slice

func Slice[K KEYS, V VALUES](arr Arrays[K, V], start, size int) Arrays[K, V]

切分数组 start 开始 size 长度

type KEYS

type KEYS interface {
	string | int | int8 | int16 | int32 | int64 | float32 | float64 | byte
}

type List

type List[K KEYS, V VALUES] struct {
	// contains filtered or unexported fields
}

func (*List[K, V]) Copy

func (l *List[K, V]) Copy(old Arrays[K, V])

数组复制将会把多维数组完全复制成为新的数组不影响旧数据 已知问题:对于底层不是 *List[K,V] 结构体的指针不做修改

func (*List[K, V]) Init

func (l *List[K, V]) Init(data map[K]V)

func (*List[K, V]) Len

func (l *List[K, V]) Len() int

func (l *List[K,V])IsEmpty() bool { return l.Len() == 0 }

func (*List[K, V]) Less

func (l *List[K, V]) Less(i, j int) bool

以下结构体方法必须重写

func (*List[K, V]) New

func (l *List[K, V]) New() Arrays[K, V]

func (*List[K, V]) Swap

func (l *List[K, V]) Swap(i, j int)

type VALUES

type VALUES any

Jump to

Keyboard shortcuts

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