set

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator[T any] struct {
	// contains filtered or unexported fields
}

func (*Iterator[T]) Clone

func (iter *Iterator[T]) Clone() *Iterator[T]

func (*Iterator[T]) Equal

func (iter *Iterator[T]) Equal(other *Iterator[T]) bool

Equal 要求颜色、父节点、左右节点、键值等全部相等

func (*Iterator[T]) IsValid

func (iter *Iterator[T]) IsValid() bool

func (*Iterator[T]) Next

func (iter *Iterator[T]) Next() *Iterator[T]

func (*Iterator[T]) Prev

func (iter *Iterator[T]) Prev() *Iterator[T]

func (*Iterator[T]) Val

func (iter *Iterator[T]) Val() T

type OpFunc

type OpFunc[T any] func(s *Set[T])

func WithRWMutex

func WithRWMutex[T any]() OpFunc[T]

WithRWMutex 赋值函数

type Set

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

func New

func New[T any](cmp compare.CmpFunc[T], ops ...OpFunc[T]) *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(val T)

Add 与insert函数一样

func (*Set[T]) Begin

func (s *Set[T]) Begin() *Iterator[T]

func (*Set[T]) Clear

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

func (*Set[T]) Delete

func (s *Set[T]) Delete(val T)

func (*Set[T]) Diff

func (s *Set[T]) Diff(set *Set[T]) *Set[T]

Diff 去差集,存在于 s 中但是不存在于 set 中的元素。 如果任一 set 是并发安全的,那么新的 set 也是并发安全的

func (*Set[T]) Erase

func (s *Set[T]) Erase(iter *Iterator[T])

func (*Set[T]) Exist

func (s *Set[T]) Exist(val T) bool

func (*Set[T]) Find

func (s *Set[T]) Find(val T) *Iterator[T]

func (*Set[T]) Insert

func (s *Set[T]) Insert(val T)

func (*Set[T]) Intersect

func (s *Set[T]) Intersect(set *Set[T]) *Set[T]

Intersect 取两个 set 的交集。如果任一 set 是并发安全的,那么新的 set 也是并发安全的

func (*Set[T]) IsLock

func (s *Set[T]) IsLock() bool

IsLock 判断 set 是否是并发安全的

func (*Set[T]) SetLock

func (s *Set[T]) SetLock()

SetLock 给 set 加锁

func (*Set[T]) Size

func (s *Set[T]) Size() int

func (*Set[T]) UnSetLock

func (s *Set[T]) UnSetLock()

UnSetLock 给 set 去掉锁

func (*Set[T]) Union

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

Union 取两个 set 的并集。如果任一 set 是并发安全的,那么新的 set 也是并发安全的

Jump to

Keyboard shortcuts

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