mattermost-community-enterp.../public/utils/array.go
Claude ec1f89217a Merge: Complete Mattermost Server with Community Enterprise
Full Mattermost server source with integrated Community Enterprise features.
Includes vendor directory for offline/air-gapped builds.

Structure:
- enterprise-impl/: Enterprise feature implementations
- enterprise-community/: Init files that register implementations
- enterprise/: Bridge imports (community_imports.go)
- vendor/: All dependencies for offline builds

Build (online):
  go build ./cmd/mattermost

Build (offline/air-gapped):
  go build -mod=vendor ./cmd/mattermost

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 23:59:07 +09:00

46 lines
1.1 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package utils
// FindExclusives returns three arrays:
// 1. Items exclusive to arr1
// 2. Items exclusive to arr2
// 3. Items common to both arr1 and arr2
func FindExclusives[T comparable](arr1, arr2 []T) ([]T, []T, []T) {
// Create maps to track the presence of elements in each array
existsInArr1 := make(map[T]bool)
existsInArr2 := make(map[T]bool)
// Populate the maps with the elements from both arrays
for _, elem := range arr1 {
existsInArr1[elem] = true
}
for _, elem := range arr2 {
existsInArr2[elem] = true
}
// Slices for results
var uniqueToArr1 []T
var uniqueToArr2 []T
var common []T
// Find elements unique to arr1 and common elements
for elem := range existsInArr1 {
if existsInArr2[elem] {
common = append(common, elem)
} else {
uniqueToArr1 = append(uniqueToArr1, elem)
}
}
// Find elements unique to arr2
for elem := range existsInArr2 {
if !existsInArr1[elem] {
uniqueToArr2 = append(uniqueToArr2, elem)
}
}
return uniqueToArr1, uniqueToArr2, common
}