Documentation
¶
Index ¶
- type Set
- type SyncSet
- func (s *SyncSet[T]) All() []T
- func (s *SyncSet[T]) Difference(set Set[T]) Set[T]
- func (s *SyncSet[T]) Do(f func(T))
- func (s *SyncSet[T]) DoE(f func(T) error) error
- func (s *SyncSet[T]) Has(element T) bool
- func (s *SyncSet[T]) Insert(elements ...T)
- func (s *SyncSet[T]) Intersection(set Set[T]) Set[T]
- func (s *SyncSet[T]) Len() int
- func (s *SyncSet[T]) ProperSubsetOf(set Set[T]) bool
- func (s *SyncSet[T]) Remove(element T)
- func (s *SyncSet[T]) SubsetOf(set Set[T]) bool
- func (s *SyncSet[T]) Union(set Set[T]) Set[T]
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 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]) Difference ¶
Difference Find the difference between two sets 返回的是自己存在而传入的 set 不存在的元素集合
func (*SyncSet[T]) Insert ¶
func (s *SyncSet[T]) Insert(elements ...T)
Insert Add element(s) to the set
func (*SyncSet[T]) Intersection ¶
Intersection Find the intersection of two sets
func (*SyncSet[T]) ProperSubsetOf ¶
ProperSubsetOf Test whether this set is a proper subset of "set"
Click to show internal directories.
Click to hide internal directories.