forked from Tufin/oasdiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
string_list.go
52 lines (43 loc) · 959 Bytes
/
string_list.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
package diff
// StringList is a list of string values
type StringList []string
func (list StringList) toStringSet() StringSet {
result := make(StringSet, len(list))
for _, s := range list {
result[s] = struct{}{}
}
return result
}
type DiffT interface {
*ExampleDiff |
*ServerDiff |
*ParameterDiff |
*VariableDiff |
*SchemaDiff |
*ResponseDiff |
*MediaTypeDiff |
*HeaderDiff |
SecurityScopesDiff |
*StringsDiff
}
func ToStringList[diff DiffT](m map[string]diff) StringList {
keys := make(StringList, len(m))
i := 0
for k := range m {
keys[i] = k
i++
}
return keys
}
// Len implements the sort.Interface interface
func (list StringList) Len() int {
return len(list)
}
// Less implements the sort.Interface interface
func (list StringList) Less(i, j int) bool {
return list[i] < list[j]
}
// Swap implements the sort.Interface interface
func (list StringList) Swap(i, j int) {
list[i], list[j] = list[j], list[i]
}