-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgentypes_ti.go
110 lines (90 loc) · 1.74 KB
/
gentypes_ti.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// This file was generated by typeinst. Do not edit, use "go generate" instead.
// nolint
package main
import (
ast "go/ast"
)
type StrSet map[string]struct{}
func NewStrSet() StrSet {
return make(map[string]struct{})
}
func (s StrSet) Add(elem string) StrSet {
s[elem] = struct{}{}
return s
}
func (s StrSet) AddMany(a ...string) StrSet {
for _, x := range a {
s[x] = struct{}{}
}
return s
}
func (s StrSet) Contains(elem string) bool {
_, ok := s[elem]
return ok
}
func (s StrSet) Copy() StrSet {
m := make(map[string]struct{})
for k := range s {
m[k] = struct{}{}
}
return m
}
func (s StrSet) AddSet(other StrSet) {
for k := range other {
s[k] = struct{}{}
}
}
func (s StrSet) Subtract(other StrSet) {
for k := range other {
delete(s, k)
}
}
func (s StrSet) ToSlice() []string {
a := make([]string, 0, len(s))
for k := range s {
a = append(a, k)
}
return a
}
type AstIdentSet map[*ast.Ident]struct{}
func NewAstIdentSet() AstIdentSet {
return make(map[*ast.Ident]struct{})
}
func (s AstIdentSet) Add(elem *ast.Ident) AstIdentSet {
s[elem] = struct{}{}
return s
}
func (s AstIdentSet) AddMany(a ...*ast.Ident) AstIdentSet {
for _, x := range a {
s[x] = struct{}{}
}
return s
}
func (s AstIdentSet) Contains(elem *ast.Ident) bool {
_, ok := s[elem]
return ok
}
func (s AstIdentSet) Copy() AstIdentSet {
m := make(map[*ast.Ident]struct{})
for k := range s {
m[k] = struct{}{}
}
return m
}
func (s AstIdentSet) AddSet(other AstIdentSet) {
for k := range other {
s[k] = struct{}{}
}
}
func (s AstIdentSet) Subtract(other AstIdentSet) {
for k := range other {
delete(s, k)
}
}
func (s AstIdentSet) ToSlice() []*ast.Ident {
a := make([]*ast.Ident, 0, len(s))
for k := range s {
a = append(a, k)
}
return a
}