-
Notifications
You must be signed in to change notification settings - Fork 3
/
inapi.pb.objs.go
113 lines (100 loc) · 1.85 KB
/
inapi.pb.objs.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
110
111
112
113
// Code generated by github.com/hooto/protobuf_slice
// source: base.proto
// DO NOT EDIT!
package inapi
import "sync"
var object_slice_mu_Label sync.RWMutex
func (it *Label) Equal(it2 *Label) bool {
if it2 == nil ||
it.Name != it2.Name ||
it.Value != it2.Value {
return false
}
return true
}
func (it *Label) Sync(it2 *Label) bool {
if it2 == nil {
return false
}
if it.Equal(it2) {
return false
}
*it = *it2
return true
}
func LabelSliceGet(ls []*Label, arg_name string) *Label {
object_slice_mu_Label.RLock()
defer object_slice_mu_Label.RUnlock()
for _, v := range ls {
if v.Name == arg_name {
return v
}
}
return nil
}
func LabelSliceDel(ls []*Label, arg_name string) ([]*Label, bool) {
object_slice_mu_Label.Lock()
defer object_slice_mu_Label.Unlock()
for i, v := range ls {
if v.Name == arg_name {
ls = append(ls[:i], ls[i+1:]...)
return ls, true
}
}
return ls, false
}
func LabelSliceEqual(ls, ls2 []*Label) bool {
object_slice_mu_Label.RLock()
defer object_slice_mu_Label.RUnlock()
if len(ls) != len(ls2) {
return false
}
hit := false
for _, v := range ls {
hit = false
for _, v2 := range ls2 {
if v.Name != v2.Name {
continue
}
if !v.Equal(v2) {
return false
}
hit = true
break
}
if !hit {
return false
}
}
return true
}
func LabelSliceSync(ls []*Label, it2 *Label) ([]*Label, bool) {
if it2 == nil {
return ls, false
}
object_slice_mu_Label.Lock()
defer object_slice_mu_Label.Unlock()
hit := false
changed := false
for i, v := range ls {
if v.Name != it2.Name {
continue
}
if !v.Equal(it2) {
ls[i], changed = it2, true
}
hit = true
break
}
if !hit {
ls = append(ls, it2)
changed = true
}
return ls, changed
}
func LabelSliceSyncSlice(ls, ls2 []*Label) ([]*Label, bool) {
if LabelSliceEqual(ls, ls2) {
return ls, false
}
return ls2, true
}