mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Delta: Allow ID duplicates
This commit is contained in:
parent
8b6e8b5c9d
commit
3c7a2afda6
1 changed files with 9 additions and 9 deletions
|
|
@ -3,27 +3,27 @@ package utils
|
|||
func Delta(a []string, b []string) ([]string, []string, []string) {
|
||||
maintained := make([]string, 0)
|
||||
dismissed := make([]string, 0)
|
||||
hash := make(map[string]bool)
|
||||
hash := make(map[string]int)
|
||||
|
||||
for _, item := range a {
|
||||
hash[item] = true
|
||||
hash[item] = 1
|
||||
}
|
||||
|
||||
for _, item := range b {
|
||||
if hash[item] {
|
||||
if hash[item] > 0 {
|
||||
maintained = append(maintained, item)
|
||||
delete(hash, item)
|
||||
hash[item] = 2
|
||||
} else {
|
||||
dismissed = append(dismissed, item)
|
||||
}
|
||||
}
|
||||
|
||||
introduced := make([]string, len(hash))
|
||||
introduced := make([]string, 0)
|
||||
|
||||
i := 0
|
||||
for k := range hash {
|
||||
introduced[i] = k
|
||||
i++
|
||||
for k, v := range hash {
|
||||
if v == 1 {
|
||||
introduced = append(introduced, k)
|
||||
}
|
||||
}
|
||||
|
||||
return introduced, maintained, dismissed
|
||||
|
|
|
|||
Loading…
Reference in a new issue