MCPcopy
hub / github.com/gogf/gf / ExampleIntSet_Add

Function ExampleIntSet_Add

container/gset/gset_z_example_int_test.go:39–48  ·  view source on GitHub ↗

Add adds one or multiple items to the set.

()

Source from the content-addressed store, hash-verified

37
38// Add adds one or multiple items to the set.
39func ExampleIntSet_Add() {
40 intSet := gset.NewIntSetFrom([]int{1, 2, 3})
41 intSet.Add(1)
42 fmt.Println(intSet.Slice())
43 fmt.Println(intSet.AddIfNotExist(1))
44
45 // May Output:
46 // [1 2 3]
47 // false
48}
49
50// AddIfNotExist checks whether item exists in the set,
51// it adds the item to set and returns true if it does not exists in the set,

Callers

nothing calls this directly

Calls 4

NewIntSetFromFunction · 0.92
AddMethod · 0.65
SliceMethod · 0.45
AddIfNotExistMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…