vector

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Vector

type Vector[T any] []T

Vector 动态数组

func New

func New[T any](capacity int) *Vector[T]

New 创建动态数组

func NewFromDocs added in v1.1.2

func NewFromDocs[T any](values ...T) *Vector[T]

NewFromDocs 从可变参数创建动态数组

func (*Vector[T]) Back added in v1.1.6

func (c *Vector[T]) Back() T

Back 获取尾部元素 注意: 未作越界检查

func (*Vector[T]) Cap added in v1.1.6

func (c *Vector[T]) Cap() int

func (*Vector[T]) Clone added in v1.1.2

func (c *Vector[T]) Clone() *Vector[T]

Clone 拷贝

func (*Vector[T]) Delete

func (c *Vector[T]) Delete(index int)

Delete 根据下标删除某个元素 性能不好, 少用

func (*Vector[T]) Elem

func (c *Vector[T]) Elem() []T

Elem 取值

func (*Vector[T]) Filter

func (c *Vector[T]) Filter(f func(i int, v T) bool) *Vector[T]

Filter 过滤

func (*Vector[T]) Front added in v1.1.6

func (c *Vector[T]) Front() T

Front 获取头部元素 注意: 未作越界检查

func (*Vector[T]) Get

func (c *Vector[T]) Get(index int) T

Get 根据下标取值

func (*Vector[T]) GroupByInt added in v1.1.7

func (c *Vector[T]) GroupByInt(transfer func(i int, v T) int) map[int][]T

GroupByInt 通过int类型字段分组

func (*Vector[T]) GroupByInt64 added in v1.1.7

func (c *Vector[T]) GroupByInt64(transfer func(i int, v T) int64) map[int64][]T

GroupByInt64 通过int64类型字段分组

func (*Vector[T]) GroupByString added in v1.1.7

func (c *Vector[T]) GroupByString(transfer func(i int, v T) string) map[string][]T

GroupByString 通过string类型字段分组

func (*Vector[T]) Len

func (c *Vector[T]) Len() int

Len 获取元素数量

func (*Vector[T]) MapInt added in v1.1.5

func (c *Vector[T]) MapInt(transfer func(i int, v T) int) *Vector[int]

MapInt 转换为int数组

func (*Vector[T]) MapInt64 added in v1.1.5

func (c *Vector[T]) MapInt64(transfer func(i int, v T) int64) *Vector[int64]

MapInt64 转换为int64数组

func (*Vector[T]) MapString added in v1.1.5

func (c *Vector[T]) MapString(transfer func(i int, v T) string) *Vector[string]

MapString 转换为字符串数组

func (*Vector[T]) PopBack added in v1.1.2

func (c *Vector[T]) PopBack() (value T)

PopBack 从尾部弹出元素

func (*Vector[T]) PopFront added in v1.1.2

func (c *Vector[T]) PopFront() (value T)

PopFront 从头部弹出元素

func (*Vector[T]) PushBack added in v1.1.2

func (c *Vector[T]) PushBack(v T)

PushBack 向尾部追加元素

func (*Vector[T]) PushFront added in v1.1.5

func (c *Vector[T]) PushFront(v T)

PushFront 向头部追加元素 性能不好, 少用

func (*Vector[T]) Range

func (c *Vector[T]) Range(f func(i int, v T) bool)

Range 遍历

func (*Vector[T]) Reset

func (c *Vector[T]) Reset()

Reset 重置

func (*Vector[T]) Reverse

func (c *Vector[T]) Reverse() *Vector[T]

func (*Vector[T]) Slice added in v1.1.2

func (c *Vector[T]) Slice(start, end int) *Vector[T]

Slice 截取子数组

func (*Vector[T]) SortByInt added in v1.1.8

func (c *Vector[T]) SortByInt(transfer func(v T) int) *Vector[T]

func (*Vector[T]) SortByInt64 added in v1.1.8

func (c *Vector[T]) SortByInt64(transfer func(v T) int64) *Vector[T]

func (*Vector[T]) SortByString added in v1.1.8

func (c *Vector[T]) SortByString(transfer func(v T) string) *Vector[T]

func (*Vector[T]) ToInt64Map added in v1.1.8

func (c *Vector[T]) ToInt64Map(transfer func(v T) int64) map[int64]T

ToInt64Map 转换为map

func (*Vector[T]) ToIntMap added in v1.1.8

func (c *Vector[T]) ToIntMap(transfer func(v T) int) map[int]T

ToIntMap 转换为map

func (*Vector[T]) ToStringMap added in v1.1.8

func (c *Vector[T]) ToStringMap(transfer func(v T) string) map[string]T

ToStringMap 转换为map

func (*Vector[T]) UniqueByInt added in v1.1.5

func (c *Vector[T]) UniqueByInt(transfer func(v T) int) *Vector[T]

UniqueByInt 通过int类型字段去重

func (*Vector[T]) UniqueByInt64 added in v1.1.5

func (c *Vector[T]) UniqueByInt64(transfer func(v T) int64) *Vector[T]

UniqueByInt64 通过int64类型字段去重

func (*Vector[T]) UniqueByString added in v1.1.5

func (c *Vector[T]) UniqueByString(transfer func(v T) string) *Vector[T]

UniqueByString 通过string类型字段去重

func (*Vector[T]) Update added in v1.1.2

func (c *Vector[T]) Update(index int, value T)

Update 根据下标修改值

Jump to

Keyboard shortcuts

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