-
Notifications
You must be signed in to change notification settings - Fork 17
/
complex128.go
58 lines (49 loc) · 1.34 KB
/
complex128.go
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
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated via go generate.
// DO NOT UPDATE MANUALLY
package set
var Complex128 = Complex128T{}
type Complex128T struct{}
// FromSlice transforms the given slice to a set.
func (Complex128T) FromSlice(els []complex128) map[complex128]struct{} {
if len(els) == 0 {
return nil
}
result := map[complex128]struct{}{}
for _, el := range els {
result[el] = struct{}{}
}
return result
}
// ToSlice transforms the given set to a slice.
func (Complex128T) ToSlice(s map[complex128]struct{}) []complex128 {
var result []complex128
for el := range s {
result = append(result, el)
}
return result
}
// Difference subtracts s2 from s1, storing the result in s1.
func (Complex128T) Difference(s1, s2 map[complex128]struct{}) {
for el := range s1 {
if _, ok := s2[el]; ok {
delete(s1, el)
}
}
}
// Intersection intersects s1 and s2, storing the result in s1.
func (Complex128T) Intersection(s1, s2 map[complex128]struct{}) {
for el := range s1 {
if _, ok := s2[el]; !ok {
delete(s1, el)
}
}
}
// Union merges s1 and s2, storing the result in s1.
func (Complex128T) Union(s1, s2 map[complex128]struct{}) {
for el := range s2 {
s1[el] = struct{}{}
}
}