set

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[K constraints.Ordered] struct {
	api.SortedMap[K, struct{}]
}

func From

func From[K constraints.Ordered](s ...K) *Set[K]

从slice创建set

func New

func New[K constraints.Ordered]() *Set[K]

创建一个空的slice

func (*Set[K]) Clone

func (s *Set[K]) Clone() (new *Set[K])

深度复制一个集合

func (*Set[K]) Diff

func (s *Set[K]) Diff(s1 *Set[K]) (new *Set[K])

返回的是s1没有的元素, s - s1

func (*Set[K]) Equal

func (s *Set[K]) Equal(s1 *Set[K]) (b bool)

两个集合是否相等

func (*Set[K]) Intersection

func (s *Set[K]) Intersection(s1 *Set[K]) (new *Set[K])

返回两个集合的公共集合

func (*Set[K]) IsMember

func (s *Set[K]) IsMember(k K) (b bool)

测试k是否在集合中

func (*Set[K]) IsSubset

func (s *Set[K]) IsSubset(s1 *Set[K]) (b bool)

测试集合s每个元素是否在s1里面, s <= s1

func (*Set[K]) IsSuperset

func (s *Set[K]) IsSuperset(s1 *Set[K]) (b bool)

测试集合s1每个元素是否在s里面 s1 <= s

func (*Set[K]) Len

func (s *Set[K]) Len() int

返回集合中元素的个数

func (*Set[K]) Range

func (s *Set[K]) Range(cb func(k K) bool)

遍历

func (*Set[K]) Set

func (s *Set[K]) Set(k K)

给集合添加元素

func (*Set[K]) ToSlice

func (s *Set[K]) ToSlice() (new []K)

func (*Set[K]) Union

func (s *Set[K]) Union(sets ...*Set[K]) (new *Set[K])

返回两个集合的所有元素

Jump to

Keyboard shortcuts

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