We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent abcdb7d commit 29bd72cCopy full SHA for 29bd72c
threadunsafe.go
@@ -42,13 +42,9 @@ func newThreadUnsafeSet[T comparable]() threadUnsafeSet[T] {
42
}
43
44
func (s *threadUnsafeSet[T]) Add(v T) bool {
45
- _, found := (*s)[v]
46
- if found {
47
- return false //False if it existed already
48
- }
49
-
+ prevLen := len(*s)
50
(*s)[v] = struct{}{}
51
- return true
+ return prevLen != len(*s)
52
53
54
func (s *threadUnsafeSet[T]) Cardinality() int {
0 commit comments