HEX
Server: Apache
System: Linux dilmahquizNew 5.14.0-162.12.1.el9_1.0.2.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan 30 22:14:42 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //usr/share/filebeat/module/cisco/shared/stringset.go
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

//go:build ignore
// +build ignore

package main

import (
	"sort"
	"strings"
)

type stringSet map[string]struct{}

func newStringSet(list []string) stringSet {
	r := stringSet{}
	for _, value := range list {
		if len(value) != 0 {
			r[value] = struct{}{}
		}
	}
	return r
}

func (set stringSet) merge(o stringSet) {
	for key := range o {
		set[key] = struct{}{}
	}
}

func (set stringSet) equal(other stringSet) bool {
	if len(set) != len(other) {
		return false
	}
	for k := range set {
		if _, found := other[k]; !found {
			return false
		}
	}
	return true
}

func (set stringSet) MarshalYAML() (interface{}, error) {
	keys := make([]string, 0, len(set))
	for key := range set {
		keys = append(keys, key)
	}
	sort.Strings(keys)
	return keys, nil
}

func (set stringSet) String() string {
	yaml, _ := set.MarshalYAML()
	return strings.Join(yaml.([]string), ", ")
}