set

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT 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] interface {

	// Len Return the number of items in the set
	Len() int

	// Has Test to see whether the element is in the set
	Has(element T) bool

	// Insert Add element(s) to the set
	Insert(elements ...T)

	// Remove an element from the set
	Remove(element T)

	// Difference Find the difference between two sets
	// 返回的是自己存在而传入的 set 不存在的元素集合
	Difference(set Set[T]) Set[T]

	All() []T

	// Do Call f for each item in the set
	Do(f func(T))

	// DoE Call f for each item in the set
	DoE(f func(T) error) error

	// Intersection Find the intersection of two sets
	Intersection(set Set[T]) Set[T]

	// ProperSubsetOf Test whether this set is a proper subset of "set"
	ProperSubsetOf(set Set[T]) bool

	// SubsetOf Test whether this set is a subset of "set"
	SubsetOf(set Set[T]) bool

	// Union Find the union of two sets
	Union(set Set[T]) Set[T]
}

func Intersection

func Intersection[T comparable](sets ...Set[T]) Set[T]

Intersection 返回若干个 set 的交集

func New

func New[T comparable](initial ...T) Set[T]

New Create a new set

func NewSyncSet

func NewSyncSet[T comparable](initial ...T) Set[T]

NewSyncSet Create a new synchronized set

type SyncSet

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

func (*SyncSet[T]) All

func (s *SyncSet[T]) All() []T

func (*SyncSet[T]) Difference

func (s *SyncSet[T]) Difference(set Set[T]) Set[T]

Difference Find the difference between two sets 返回的是自己存在而传入的 set 不存在的元素集合

func (*SyncSet[T]) Do

func (s *SyncSet[T]) Do(f func(T))

Do Call f for each item in the set

func (*SyncSet[T]) DoE

func (s *SyncSet[T]) DoE(f func(T) error) error

DoE Call f for each item in the set

func (*SyncSet[T]) Has

func (s *SyncSet[T]) Has(element T) bool

Has Test to see whether the element is in the set

func (*SyncSet[T]) Insert

func (s *SyncSet[T]) Insert(elements ...T)

Insert Add element(s) to the set

func (*SyncSet[T]) Intersection

func (s *SyncSet[T]) Intersection(set Set[T]) Set[T]

Intersection Find the intersection of two sets

func (*SyncSet[T]) Len

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

Len Return the number of items in the set

func (*SyncSet[T]) ProperSubsetOf

func (s *SyncSet[T]) ProperSubsetOf(set Set[T]) bool

ProperSubsetOf Test whether this set is a proper subset of "set"

func (*SyncSet[T]) Remove

func (s *SyncSet[T]) Remove(element T)

Remove an element from the set

func (*SyncSet[T]) SubsetOf

func (s *SyncSet[T]) SubsetOf(set Set[T]) bool

SubsetOf Test whether this set is a subset of "set"

func (*SyncSet[T]) Union

func (s *SyncSet[T]) Union(set Set[T]) Set[T]

Union Find the union of two sets

Jump to

Keyboard shortcuts

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