good morning!!!!

Skip to content
Snippets Groups Projects
Verified Commit 77934263 authored by a's avatar a
Browse files

delete more code

parent 9b08938e
No related branches found
No related tags found
No related merge requests found
Pipeline #31627 passed with stage
in 3 minutes and 54 seconds
package mapset
import "sync"
type Set[T comparable] struct {
m map[T]struct{}
mu sync.RWMutex
}
func NewSet[T comparable]() *Set[T] {
return &Set[T]{
m: make(map[T]struct{}),
}
}
func (s *Set[T]) Add(x T) {
s.mu.Lock()
defer s.mu.Unlock()
s.m[x] = struct{}{}
}
func (s *Set[T]) Remove(x T) {
s.mu.Lock()
defer s.mu.Unlock()
delete(s.m, x)
}
func (s *Set[T]) Each(fn func(x T) bool) {
s.mu.RLock()
defer s.mu.RUnlock()
for k := range s.m {
if !fn(k) {
return
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment