set

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[T Value] struct {
	// contains filtered or unexported fields
}

Set 结构存储不重复的字符串数组

var (
	Empty Set[int]
)

EmptySet 为一个固定的空 Set 结构, 经常用来复用, 避免创建太多的空 Set

func New

func New[T Value](args ...T) Set[T]

NewSet 创建一个新的 Set 结构并返回

func (Set[T]) Add

func (set Set[T]) Add(other Set[T]) Set[T]

Add 将两个 set 合并并返回新 set, 不改变原数据

func (Set[T]) Clear

func (set Set[T]) Clear()

Clear 清空 Set 中元素

func (Set[T]) Del

func (set Set[T]) Del(value T)

Del 从 Set 中删除元素

func (Set[T]) Has

func (set Set[T]) Has(value T) bool

Has 检验 Set 是否包含某值

func (Set[T]) Insert

func (set Set[T]) Insert(value T)

Insert 向 Set 中添加元素

func (*Set[T]) IsEmpty

func (set *Set[T]) IsEmpty() bool

IsEmpty 判断 Set 结构是不是 Zero Value

func (*Set[T]) IsZero

func (set *Set[T]) IsZero() bool

IsZero 判断 Set 结构是不是 Zero Value

func (Set[T]) Len

func (set Set[T]) Len() int

Len 返回元素的个数

func (Set[T]) MarshalJSON

func (set Set[T]) MarshalJSON() ([]byte, error)

MarshalJSON encode status value into json

func (*Set[T]) Scan

func (set *Set[T]) Scan(src any) error

Scan 将 mysql 查询出的结果存储变量 set 中

func (Set[T]) Slice

func (set Set[T]) Slice() []T

Slice 返回 Set 的切片结构

func (Set[T]) String

func (set Set[T]) String() string

func (Set[T]) Sub

func (set Set[T]) Sub(other Set[T]) Set[T]

Sub 求 set - other 并返回

func (Set[T]) Union

func (set Set[T]) Union(other Set[T]) Set[T]

Union 求两个 set 集合的并集

func (*Set[T]) UnmarshalJSON

func (set *Set[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON decode status value from json

func (Set[T]) Value

func (set Set[T]) Value() (driver.Value, error)

Value 实现 driver.Valuer,使得该结构可用于 mysql 的存储

type Value

type Value interface {
	int | string | int64 | int32 | int16 | int8 | uint32 | uint64 | uint16 | uint8 | float64 | float32
}

Jump to

Keyboard shortcuts

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