data

package
v0.0.0-...-0e42c13 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIncludingSelf

func CheckIncludingSelf(typ IsItARecursiveType) (errcode.ErrCode, errcode.Msg)

Check Including self 检查是否包含自身

Types

type IsItARecursiveType

type IsItARecursiveType interface {
	My() string
	//Dependencies
	Dep() []IsItARecursiveType
}

IsItARecursiveType 表示可能是递归类型

type OnceValue

type OnceValue[T any] struct {
	IsSet bool
	// contains filtered or unexported fields
}

缩写:Set value only once缩写成 OnceValue

只设置一次的值

TODO:当最低需要go1.21时,改为标准库实现

func (*OnceValue[T]) Get

func (o *OnceValue[T]) Get() (T, bool)

Get 获取值,已经是否设置过

func (*OnceValue[T]) Set

func (o *OnceValue[T]) Set(value T)

Set 设置值,如果已经设置过,不会重复设置

type RemoveDupStrck

type RemoveDupStrck[T comparable] struct {
	Slice[T]
	// contains filtered or unexported fields
}

RemoveDupStrck 能去除重复元素的栈

func NewRemoveDupStrck

func NewRemoveDupStrck[T comparable](thread bool) RemoveDupStrck[T]

func (*RemoveDupStrck[T]) Len

func (s *RemoveDupStrck[T]) Len() int

Len 返回栈中有多少数据

func (*RemoveDupStrck[T]) Push

func (s *RemoveDupStrck[T]) Push(value T)

Push 如果栈中没有值,则入栈

func (*RemoveDupStrck[T]) Range

func (s *RemoveDupStrck[T]) Range(f func(T))

Range 从栈底开始遍历到栈顶

type Slice

type Slice[T any] struct {
	Data []T

	Thread bool
	// contains filtered or unexported fields
}

Slice 是可以并发安全的切片(Thread=true)

func NewSilce

func NewSilce[T any](Thread bool, capnum int) *Slice[T]

func (*Slice[T]) Add

func (s *Slice[T]) Add(value T)

Add 添加一个值到末尾,可以从多个goroutine同时调用(Thread=true)

func (*Slice[T]) AddSlice

func (s *Slice[T]) AddSlice(value []T)

AddSlice 添加一个切片到末尾,可以从多个goroutine同时调用(Thread=true)

Jump to

Keyboard shortcuts

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