Example demonstrates basic usage of generic Set with integers
()
| 25 | |
| 26 | // Example demonstrates basic usage of generic Set with integers |
| 27 | func 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 |
| 51 | func ExampleSet_intSet() { |
nothing calls this directly
no test coverage detected