baizeSet

package
v0.0.0-...-7bb2ca5 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 1 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 comparable] map[T]struct{}

Set 利用泛型,定义一个泛型类型(set), 泛型的写法使用中括号,comparable是新增的一个内置类型

func (Set[T]) Add

func (s Set[T]) Add(v T)

Add 向set中添加元素

func (Set[T]) AddAll

func (s Set[T]) AddAll(vs ...T)

AddAll 向set中添加多个元素

func (Set[T]) Clear

func (s Set[T]) Clear() Set[T]

Clear 清空set

func (Set[T]) Contains

func (s Set[T]) Contains(v T) bool

Contains 查询某个元素v是否在set中

func (Set[T]) Len

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

Len 获取set的长度

func (Set[T]) Remove

func (s Set[T]) Remove(v T)

Remove 移除set中某个元素

func (Set[T]) RemoveAll

func (s Set[T]) RemoveAll(vs ...T)

RemoveAll 移除set中多个元素

func (Set[T]) String

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

实现String方法,优化set的打印效果

func (Set[T]) ToSlice

func (s Set[T]) ToSlice() []T

ToSlice set转slice

Jump to

Keyboard shortcuts

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