MCPcopy
hub / github.com/minio/minio-go / Example

Function Example

pkg/set/example_test.go:27–48  ·  view source on GitHub ↗

Example demonstrates basic usage of generic Set with integers

()

Source from the content-addressed store, hash-verified

25
26// Example demonstrates basic usage of generic Set with integers
27func Example() {
28 // Create a new set of integers
29 s := set.Create(1, 2, 3, 4, 5)
30
31 // Add an element
32 s.Add(6)
33
34 // Check if element exists
35 fmt.Println("Contains 3:", s.Contains(3))
36 fmt.Println("Contains 10:", s.Contains(10))
37
38 // Remove an element
39 s.Remove(2)
40
41 // Get sorted slice
42 fmt.Println("Elements:", set.ToSliceOrdered(s))
43
44 // Output:
45 // Contains 3: true
46 // Contains 10: false
47 // Elements: [1 3 4 5 6]
48}
49
50// ExampleSet_intSet demonstrates set operations with integers
51func ExampleSet_intSet() {

Callers

nothing calls this directly

Calls 5

CreateFunction · 0.92
ToSliceOrderedFunction · 0.92
AddMethod · 0.45
ContainsMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected