set

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentHashSet deprecated

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

ConcurrentHashSet is a thread-safe set implementation that uses a Golang builtin map to store its elements.

Deprecated: Use the SyncSet instead.

func NewConcurrentHashSet deprecated

func NewConcurrentHashSet[T comparable]() *ConcurrentHashSet[T]

NewConcurrentHashSet creates and returns am empty ConcurrentHashSet with the specified type.

Deprecated: Use the NewSyncSet instead.

func (*ConcurrentHashSet[T]) Add

func (set *ConcurrentHashSet[T]) Add(e T) bool

Add adds the specified element to this set.

func (*ConcurrentHashSet[T]) AddAll

func (set *ConcurrentHashSet[T]) AddAll(c ...T) bool

AddAll adds all of the specified elements to this set.

func (*ConcurrentHashSet[T]) Clear

func (set *ConcurrentHashSet[T]) Clear()

Clear removes all of the elements from this set.

func (*ConcurrentHashSet[T]) Clone

func (set *ConcurrentHashSet[T]) Clone() collection.Set[T]

Clone returns a copy of this set.

func (*ConcurrentHashSet[T]) Contains

func (set *ConcurrentHashSet[T]) Contains(e T) bool

Contains returns true if this set contains the specified element.

func (*ConcurrentHashSet[T]) ContainsAll

func (set *ConcurrentHashSet[T]) ContainsAll(c ...T) bool

ContainsAll returns true if this set contains all of the specified elements.

func (*ConcurrentHashSet[T]) Equals

func (set *ConcurrentHashSet[T]) Equals(o any) bool

Equals compares set with the object pass from parameter.

func (*ConcurrentHashSet[T]) ForEach

func (set *ConcurrentHashSet[T]) ForEach(handler func(e T) error) error

ForEach performs the given handler for each elements in the set until all elements have been processed or the handler returns an error.

func (*ConcurrentHashSet[T]) IsEmpty

func (set *ConcurrentHashSet[T]) IsEmpty() bool

IsEmpty returns true if this set contains no elements.

func (*ConcurrentHashSet[T]) Iter

func (set *ConcurrentHashSet[T]) Iter() iter.Seq[T]

Iter returns a channel of all elements in this set.

func (*ConcurrentHashSet[T]) Remove

func (set *ConcurrentHashSet[T]) Remove(e T) bool

Remove removes the specified element from this set.

func (*ConcurrentHashSet[T]) RemoveAll

func (set *ConcurrentHashSet[T]) RemoveAll(c ...T) bool

RemoveAll removes all of the specified elements from this set.

func (*ConcurrentHashSet[T]) RemoveIf added in v0.3.1

func (set *ConcurrentHashSet[T]) RemoveIf(filter func(T) bool) bool

RemoveIf removes all of the elements of this set that satisfy the given predicate.

func (*ConcurrentHashSet[T]) RetainAll added in v0.3.1

func (set *ConcurrentHashSet[T]) RetainAll(c ...T) bool

RetainAll retains only the elements in this set that are contained in the specified collection.

func (*ConcurrentHashSet[T]) Size

func (set *ConcurrentHashSet[T]) Size() int

Size returns the number of elements in this set.

func (*ConcurrentHashSet[T]) ToSlice

func (set *ConcurrentHashSet[T]) ToSlice() []T

ToSlice returns a slice containing all of the elements in this set.

type HashSet

type HashSet[T comparable] map[T]empty

HashSet is a set implementation that uses a Golang builtin map to store its elements.

func NewHashSet

func NewHashSet[T comparable]() *HashSet[T]

NewHashSet creates a new HashSet.

func (*HashSet[T]) Add

func (set *HashSet[T]) Add(e T) bool

Add adds the specified element to this set.

func (*HashSet[T]) AddAll

func (set *HashSet[T]) AddAll(c ...T) bool

AddAll adds all of the specified elements to this set.

func (*HashSet[T]) Clear

func (set *HashSet[T]) Clear()

Clear removes all of the elements from this set.

func (*HashSet[T]) Clone

func (set *HashSet[T]) Clone() collection.Set[T]

Clone returns a copy of this set.

func (*HashSet[T]) Contains

func (set *HashSet[T]) Contains(e T) bool

Contains returns true if this set contains the specified element.

func (*HashSet[T]) ContainsAll

func (set *HashSet[T]) ContainsAll(c ...T) bool

ContainsAll returns true if this set contains all of the specified elements.

func (*HashSet[T]) Equals

func (set *HashSet[T]) Equals(o any) bool

Equals compares set with the object pass from parameter.

func (*HashSet[T]) ForEach

func (set *HashSet[T]) ForEach(handler func(e T) error) error

ForEach performs the given handler for each elements in the set until all elements have been processed or the handler returns an error.

func (*HashSet[T]) IsEmpty

func (set *HashSet[T]) IsEmpty() bool

IsEmpty returns true if this set contains no elements.

func (*HashSet[T]) Iter

func (set *HashSet[T]) Iter() iter.Seq[T]

Iter returns a channel of all elements in this set.

func (*HashSet[T]) Remove

func (set *HashSet[T]) Remove(e T) bool

Remove removes the specified element from this set.

func (*HashSet[T]) RemoveAll

func (set *HashSet[T]) RemoveAll(c ...T) bool

RemoveAll removes all of the specified elements from this set.

func (*HashSet[T]) RemoveIf added in v0.3.1

func (set *HashSet[T]) RemoveIf(filter func(T) bool) bool

RemoveIf removes all of the elements of this set that satisfy the given predicate.

func (*HashSet[T]) RetainAll added in v0.3.1

func (set *HashSet[T]) RetainAll(c ...T) bool

RetainAll retains only the elements in this set that are contained in the specified collection.

func (*HashSet[T]) Size

func (set *HashSet[T]) Size() int

Size returns the number of elements in this set.

func (*HashSet[T]) ToSlice

func (set *HashSet[T]) ToSlice() []T

ToSlice returns a slice containing all of the elements in this set.

type SyncSet added in v0.3.0

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

func NewSyncSet added in v0.3.0

func NewSyncSet[T comparable]() *SyncSet[T]

func (*SyncSet[T]) Add added in v0.3.0

func (s *SyncSet[T]) Add(val T) bool

Add adds the specified element to this collection.

func (*SyncSet[T]) AddAll added in v0.3.0

func (s *SyncSet[T]) AddAll(c ...T) bool

AddAll adds all of the elements in the this collection.

func (*SyncSet[T]) Clear added in v0.3.0

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

Clear removes all of the elements from this collection.

func (*SyncSet[T]) Clone added in v0.3.0

func (s *SyncSet[T]) Clone() collection.Set[T]

Clone returns a copy of this set.

func (*SyncSet[T]) Contains added in v0.3.0

func (s *SyncSet[T]) Contains(e T) bool

Contains returns true if this collection contains the specified element.

func (*SyncSet[T]) ContainsAll added in v0.3.0

func (s *SyncSet[T]) ContainsAll(c ...T) bool

ContainsAll returns true if this collection contains all of the elements in the specified collection.

func (*SyncSet[T]) Equals added in v0.3.0

func (s *SyncSet[T]) Equals(o any) bool

Equals compares this collection with the object pass from parameter.

func (*SyncSet[T]) ForEach added in v0.3.0

func (s *SyncSet[T]) ForEach(handler func(e T) error) error

ForEach performs the given handler for each elements in the collection until all elements have been processed or the handler returns an error.

func (*SyncSet[T]) IsEmpty added in v0.3.0

func (s *SyncSet[T]) IsEmpty() bool

IsEmpty returns true if this collection contains no elements.

func (*SyncSet[T]) Iter added in v0.3.0

func (set *SyncSet[T]) Iter() iter.Seq[T]

Iter returns a channel of all elements in this set.

func (*SyncSet[T]) Remove added in v0.3.0

func (s *SyncSet[T]) Remove(k T) bool

Remove removes the specified element from this collection.

func (*SyncSet[T]) RemoveAll added in v0.3.0

func (s *SyncSet[T]) RemoveAll(c ...T) bool

RemoveAll removes all of the elements in the specified collection from this collection.

func (*SyncSet[T]) RemoveIf added in v0.3.1

func (s *SyncSet[T]) RemoveIf(filter func(T) bool) bool

RemoveIf removes all of the elements of this collection that satisfy the given predicate.

func (*SyncSet[T]) RetainAll added in v0.3.1

func (s *SyncSet[T]) RetainAll(c ...T) bool

RetainAll retains only the elements in this collection that are contained in the specified collection.

func (*SyncSet[T]) Size added in v0.3.0

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

Size returns the number of elements in this collection.

func (*SyncSet[T]) ToSlice added in v0.3.0

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

ToSlice returns a slice containing all of the elements in this collection.

Jump to

Keyboard shortcuts

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