-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
47 lines (36 loc) · 847 Bytes
/
main.go
File metadata and controls
47 lines (36 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"math"
set "github.com/pitakill/go-set/internal"
)
func main() {
s0 := set.NewSet("Earth", 2020, math.MaxInt32)
fmt.Println(s0.Set())
// Add elements
s0.Add("Venus", "Mars")
fmt.Println(s0.Set())
// Remove elements
s0.Remove("Venus")
fmt.Println(s0.Set())
// Union with different Set
s1 := set.NewSet("Sun")
union := s0.Union(s1)
fmt.Println(union.Set())
// Intersection with other Set
s2 := set.NewSet("Mercury", "Venus", "Earth", "Mars")
intersection := s0.Intersection(s2)
fmt.Println(intersection.Set())
// Complement
complement := s0.Complement(s2)
fmt.Println(complement.Set())
// Cartesian Product
cp := s0.CartesianProduct(s1)
fmt.Println(cp.Set())
// Cardinality
c := cp.Cardinality()
fmt.Println(c)
// Contains
contains := s0.Contains("Mars")
fmt.Println(contains)
}