Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentHashSet ¶
type ConcurrentHashSet[T comparable] struct { // contains filtered or unexported fields }
ConcurrentHashSet is a work-in-progress experimental thread-safe set implementation that uses atomic operations and sync.Map. !!! This implementation is not yet optimized and may contain bugs. For stable usage, prefer SynchronizedHashSet. Deprecated.
func NewConcurrentHashSet ¶
func NewConcurrentHashSet[T comparable]() *ConcurrentHashSet[T]
NewConcurrentHashSet creates a new instance of ConcurrentHashSet with default Farm64 hash implementation
func NewCustomConcurrentHashSet ¶
func NewCustomConcurrentHashSet[T comparable](hash func(value *T) uint64) *ConcurrentHashSet[T]
NewCustomConcurrentHashSet creates a new instance of ConcurrentHashSet with specific hashing implementation
func (*ConcurrentHashSet[T]) Add ¶
func (s *ConcurrentHashSet[T]) Add(value T) bool
Add inserts a value into the set
func (*ConcurrentHashSet[T]) Clear ¶
func (s *ConcurrentHashSet[T]) Clear()
Clear removes all elements from the set
func (*ConcurrentHashSet[T]) Contains ¶
func (s *ConcurrentHashSet[T]) Contains(value T) bool
Contains checks if a value is present in the set
func (*ConcurrentHashSet[T]) Remove ¶
func (s *ConcurrentHashSet[T]) Remove(value T) bool
Remove deletes a value from the set
func (*ConcurrentHashSet[T]) Size ¶
func (s *ConcurrentHashSet[T]) Size() int
Size returns the number of elements in the set
type HashSet ¶
type HashSet[T comparable] struct { // contains filtered or unexported fields }
HashSet is a generic set data structure that ensures all elements are unique. It uses a map to provide efficient operations for adding, removing, and checking elements.
func NewHashSet ¶
func NewHashSet[T comparable]() *HashSet[T]
NewHashSet creates a new instance of HashSet with the default size
func NewHashSetWithSize ¶
func NewHashSetWithSize[T comparable](size int) *HashSet[T]
NewHashSetWithSize creates a new instance of HashSet with a specified initial size
func (*HashSet[T]) Add ¶
Add inserts a value into the set and returns true if the value was not already present
func (*HashSet[T]) Clear ¶
func (s *HashSet[T]) Clear()
Clear returns the number of elements in the set
type Set ¶
type Set[T comparable] interface { Add(value T) bool Contains(value T) bool Remove(value T) bool Size() int Clear() }
type SynchronizedHashSet ¶
type SynchronizedHashSet[T comparable] struct { // contains filtered or unexported fields }
SynchronizedHashSet is a thread-safe wrapper around HashSet that ensures concurrent safety.
func NewSynchronizedHashSet ¶
func NewSynchronizedHashSet[T comparable]() *SynchronizedHashSet[T]
func NewSynchronizedHashSetFromSet ¶
func NewSynchronizedHashSetFromSet[T comparable](hs *HashSet[T]) *SynchronizedHashSet[T]
func (*SynchronizedHashSet[T]) Add ¶
func (s *SynchronizedHashSet[T]) Add(value T) bool
func (*SynchronizedHashSet[T]) Clear ¶
func (s *SynchronizedHashSet[T]) Clear()
func (*SynchronizedHashSet[T]) Contains ¶
func (s *SynchronizedHashSet[T]) Contains(value T) bool
func (*SynchronizedHashSet[T]) Remove ¶
func (s *SynchronizedHashSet[T]) Remove(value T) bool
func (*SynchronizedHashSet[T]) Size ¶
func (s *SynchronizedHashSet[T]) Size() int