// MergeMap implements openapi
760646
func (v *mapSchemaVisitor) VisitMap(result *proto.Map) {
	v.Result = result
	v.Kind = "map"
}
97372
func buildMap(v reflect.Value, onlyFields []string) map[string]interface{} {
	res := make(map[string]interface{})
	if onlyFields != nil {
		for _, onlyField := range onlyFields {
			fieldType, exist := v.Type().FieldByName(onlyField)
			if exist {
				addFieldToMap(true, fieldType, v.FieldByName(onlyField), res)
			}
		}
	} else {
		for i := 0; i < v.NumField(); i++ {
			addFieldToMap(false, v.Type().Field(i), v.Field(i), res)
		}
	}
	return res
}
1213063
func mergeAuthorizationMaps(newAuths []AuthorizationMap, oldAuths []AuthorizationMap) []AuthorizationMap {
OLDAUTHS:
	for _, oldAuth := range oldAuths {
		// check all new auths to make sure it isn't overwritten
		for _, newAuth := range newAuths {
			// overwritten, continue with the next oldAuth
			if oldAuth.RequestedLabel == newAuth.RequestedLabel {
				continue OLDAUTHS
			}
		}
		// All new auths checked and no match, so lets append it
		newAuths = append(newAuths, oldAuth)
	}

	return newAuths
}
805403
func mergeConditionMap(condMap1 ConditionMap, condMap2 ConditionMap) ConditionMap {
	out := make(ConditionMap)

	for k, v := range condMap1 {
		out[k] = CopyConditionKeyMap(v)
	}

	for k, v := range condMap2 {
		if ev, ok := out[k]; ok {
			out[k] = mergeConditionKeyMap(ev, v)
		} else {
			out[k] = CopyConditionKeyMap(v)
		}
	}

	return out
}
524620
func AddMaps(a, b map[string]string) map[string]string {
	if len(a) == 0 {
		if len(b) == 0 {
			return map[string]string{}
		}
		return b
	}
	if len(b) == 0 {
		return a
	}
	r := make(map[string]string, len(a)+len(b))
	for k, v := range a {
		r[k] = v
	}
	for k, v := range b {
		r[k] = v
	}
	return r
}
1336340
func RenderMap(v interface{}, ctx *Context, f *RenderFilter) (map[string]interface{}, error) {
	// First decode it into the map
	var m map[string]interface{}
	if err := mapstructure.Decode(v, &m); err != nil {
		return nil, err
	}

	// Now go through each value and render it
	for k, raw := range m {
		// Always validate every field
		if err := ValidateInterface(raw, ctx); err != nil {
			return nil, fmt.Errorf("invalid '%s': %s", k, err)
		}

		if !f.include(k) {
			continue
		}

		raw, err := RenderInterface(raw, ctx)
		if err != nil {
			return nil, fmt.Errorf("render '%s': %s", k, err)
		}

		m[k] = raw
	}

	return m, nil
}
776708
func (v delegatingStrategy) MergeMap(diff apply.MapElement) (apply.Result, error) {
	switch diff.GetFieldMergeType() {
	case apply.MergeStrategy:
		return v.merge.MergeMap(diff)
	case apply.ReplaceStrategy:
		return v.replace.MergeMap(diff)
	case apply.RetainKeysStrategy:
		return v.retainKeys.MergeMap(diff)
	default:
		return v.merge.MergeMap(diff)
	}
}
1038016
func mergeValues(d map[string]interface{}, o map[string]interface{}) map[string]interface{} {
	def := copyMap(d)
	over := copyMap(o)
	for k, v := range over {
		// If the key doesn't exist already, then just set the key to that value
		if _, exists := def[k]; !exists {
			def[k] = v
			continue
		}
		nextMap, ok := v.(map[string]interface{})
		// If it isn't another map, overwrite the value
		if !ok {
			def[k] = v
			continue
		}
		// Edge case: If the key exists in the default, but isn't a map
		defMap, isMap := def[k].(map[string]interface{})
		// If the override map has a map for this key, prefer it
		if !isMap {
			def[k] = v
			continue
		}
		// If we got to this point, it is a map in both, so merge them
		def[k] = mergeValues(defMap, nextMap)
	}
	return def
}
844165
func (s *JSONSchema) Merge(other *JSONSchema) {
	items := s.createMergeItems(other)
	for _, v := range items {
		if v.needed && v.b != nil {
			reflect.Indirect(reflect.ValueOf(v.a)).Set(reflect.ValueOf(v.b))
		}
	}

	for n, p := range other.Properties {
		if _, ok := s.Properties[n]; !ok {
			if s.Properties == nil {
				s.Properties = make(map[string]*JSONSchema)
			}
			s.Properties[n] = p
		}
	}

	for n, d := range other.Definitions {
		if _, ok := s.Definitions[n]; !ok {
			s.Definitions[n] = d
		}
	}

	for _, l := range other.Links {
		s.Links = append(s.Links, l)
	}

	for _, r := range other.Required {
		s.Required = append(s.Required, r)
	}
}
1004199
func merge(maps ...map[string]string) map[string]string {
	var output map[string]string = nil
	for _, m := range maps {
		if m != nil && output == nil {
			output = map[string]string{}
		}
		for k, v := range m {
			output[k] = v
		}
	}
	return output
}
310904
func (o Object) Merge(other Object) {
	for n, att := range other {
		o[n] = DupAtt(att)
	}
}
840491
func (criteria *Criteria) MergeOptions(newOptions OptionValue) {
	options := make(map[string]interface{})
	for k, v := range criteria.Options {
		options[k] = v
	}

	for k, v := range newOptions {
		options[k] = v
	}

	criteria.Options = OptionValue(options)
}
372998
func MergeIndexMaps(map1, map2 []int) []int {
	result := make([]int, len(map2))
	for i, v := range map2 {
		result[i] = map1[v]
	}

	return result
}
534416
func (p *trie) merge(m matcher) (matcher, error) {
	other, ok := m.(*trie)
	if !ok {
		return nil, fmt.Errorf("Can't merge %T and %T", p, m)
	}
	mapper := p.mapper.equivalent(other.mapper)
	if mapper == nil {
		return nil, fmt.Errorf("Can't merge %T and %T", p, m)
	}

	root, err := p.root.merge(other.root)
	if err != nil {
		return nil, err
	}
	return &trie{root: root, mapper: mapper}, nil
}
203088
func CreateTwoWayMergeMapPatch(original, modified JSONMap, dataStruct interface{}, fns ...mergepatch.PreconditionFunc) (JSONMap, error) {
	schema, err := NewPatchMetaFromStruct(dataStruct)
	if err != nil {
		return nil, err
	}

	return CreateTwoWayMergeMapPatchUsingLookupPatchMeta(original, modified, schema, fns...)
}
232185
func CreateMap(values ...interface{}) (map[string]interface{}, error) {
	if len(values)%2 != 0 {
		return nil, errors.New("invalid map call")
	}
	dict := make(map[string]interface{}, len(values)/2)
	for i := 0; i < len(values); i += 2 {
		key, ok := values[i].(string)
		if !ok {
			return nil, errors.New("map keys must be strings")
		}
		dict[key] = values[i+1]
	}
	return dict, nil
}
360220
func (t Term) ConcatMap(args ...interface{}) Term {
	return constructMethodTerm(t, "ConcatMap", p.Term_CONCAT_MAP, funcWrapArgs(args), map[string]interface{}{})
}