ExampleSet_intSet demonstrates set operations with integers
()
| 49 | |
| 50 | // ExampleSet_intSet demonstrates set operations with integers |
| 51 | func ExampleSet_intSet() { |
| 52 | setA := set.Create(1, 2, 3, 4) |
| 53 | setB := set.Create(3, 4, 5, 6) |
| 54 | |
| 55 | // Union |
| 56 | union := setA.Union(setB) |
| 57 | fmt.Println("Union:", set.ToSliceOrdered(union)) |
| 58 | |
| 59 | // Intersection |
| 60 | intersection := setA.Intersection(setB) |
| 61 | fmt.Println("Intersection:", set.ToSliceOrdered(intersection)) |
| 62 | |
| 63 | // Difference |
| 64 | difference := setA.Difference(setB) |
| 65 | fmt.Println("Difference:", set.ToSliceOrdered(difference)) |
| 66 | |
| 67 | // Output: |
| 68 | // Union: [1 2 3 4 5 6] |
| 69 | // Intersection: [3 4] |
| 70 | // Difference: [1 2] |
| 71 | } |
| 72 | |
| 73 | // ExampleSet_stringSet demonstrates using generic Set with strings |
| 74 | func ExampleSet_stringSet() { |
nothing calls this directly
no test coverage detected