AddIfNotExistFunc checks whether item exists in the set, it adds the item to set and returns true if it does not exists in the set and function `f` returns true, or else it does nothing and returns false. Note that, the function `f` is executed without writing lock.
()
| 83 | // or else it does nothing and returns false. |
| 84 | // Note that, the function `f` is executed without writing lock. |
| 85 | func ExampleIntSet_AddIfNotExistFuncLock() { |
| 86 | intSet := gset.NewIntSetFrom([]int{1, 2, 3}) |
| 87 | intSet.Add(1) |
| 88 | fmt.Println(intSet.Slice()) |
| 89 | fmt.Println(intSet.AddIfNotExistFuncLock(4, func() bool { |
| 90 | return true |
| 91 | })) |
| 92 | |
| 93 | // May Output: |
| 94 | // [1 2 3] |
| 95 | // true |
| 96 | } |
| 97 | |
| 98 | // Clear deletes all items of the set. |
| 99 | func ExampleIntSet_Clear() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…