// CreateFromMap returns a Data object with keys and values matching
// the map.
487805
func CreateFromMap(m map[string]string) *Data {
	data := newData()
	for key, value := range m {
		data.Add(key, value)
	}
	return data
}
816384
func (c *client) newParamMap(key string, value interface{}) map[string]string {
	ret := make(map[string]string, len(c.params)+1)
	for key, value := range c.params {
		ret[key] = value
	}
	jsonVal, _ := json.Marshal(value)
	ret[key] = string(jsonVal)
	return ret
}
649188
func NewFuncMap() []template.FuncMap {
	return []template.FuncMap{map[string]interface{}{
		"GoVer": func() string {
			return strings.Title(runtime.Version())
		},
		"UseHTTPS": func() bool {
			return strings.HasPrefix(setting.AppURL, "https")
		},
		"AppName": func() string {
			return setting.AppName
		},
		"AppSubURL": func() string {
			return setting.AppSubURL
		},
		"AppURL": func() string {
			return setting.AppURL
		},
		"AppVer": func() string {
			return setting.AppVer
		},
		"AppDomain": func() string {
			return setting.Domain
		},
		"DisableGravatar": func() bool {
			return setting.DisableGravatar
		},
		"ShowFooterTemplateLoadTime": func() bool {
			return setting.ShowFooterTemplateLoadTime
		},
		"LoadTimes": func(startTime time.Time) string {
			return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms"
		},
		"AvatarLink":       tool.AvatarLink,
		"AppendAvatarSize": tool.AppendAvatarSize,
		"Safe":             Safe,
		"Sanitize":         bluemonday.UGCPolicy().Sanitize,
		"Str2HTML":         Str2HTML,
		"NewLine2br":       NewLine2br,
		"TimeSince":        tool.TimeSince,
		"RawTimeSince":     tool.RawTimeSince,
		"FileSize":         tool.FileSize,
		"Subtract":         tool.Subtract,
		"Add": func(a, b int) int {
			return a + b
		},
		"ActionIcon": ActionIcon,
		"DateFmtLong": func(t time.Time) string {
			return t.Format(time.RFC1123Z)
		},
		"DateFmtShort": func(t time.Time) string {
			return t.Format("Jan 02, 2006")
		},
		"List": List,
		"SubStr": func(str string, start, length int) string {
			if len(str) == 0 {
				return ""
			}
			end := start + length
			if length == -1 {
				end = len(str)
			}
			if len(str) < end {
				return str
			}
			return str[start:end]
		},
		"Join":              strings.Join,
		"EllipsisString":    tool.EllipsisString,
		"DiffTypeToStr":     DiffTypeToStr,
		"DiffLineTypeToStr": DiffLineTypeToStr,
		"Sha1":              Sha1,
		"ShortSHA1":         tool.ShortSHA1,
		"MD5":               tool.MD5,
		"ActionContent2Commits": ActionContent2Commits,
		"EscapePound":           EscapePound,
		"RenderCommitMessage":   RenderCommitMessage,
		"ThemeColorMetaTag": func() string {
			return setting.UI.ThemeColorMetaTag
		},
		"FilenameIsImage": func(filename string) bool {
			mimeType := mime.TypeByExtension(filepath.Ext(filename))
			return strings.HasPrefix(mimeType, "image/")
		},
		"TabSizeClass": func(ec *editorconfig.Editorconfig, filename string) string {
			if ec != nil {
				def := ec.GetDefinitionForFilename(filename)
				if def.TabWidth > 0 {
					return fmt.Sprintf("tab-size-%d", def.TabWidth)
				}
			}
			return "tab-size-8"
		},
	}}
}
1244837
func (v *Value) ObjxMap(optionalDefault ...(Map)) Map {
	if s, ok := v.data.((Map)); ok {
		return s
	}
	if s, ok := v.data.(map[string]interface{}); ok {
		return s
	}
	if len(optionalDefault) == 1 {
		return optionalDefault[0]
	}
	return New(nil)
}
1279769
func HeadersFromMap(m map[string]string) Headers {
	if len(m) == 0 {
		return Headers{}
	}
	headers := NewHeadersWithCapacity(len(m))
	for k, v := range m {
		headers = headers.With(k, v)
	}
	return headers
}
1055997
func CreateMultipartMetadata(metadata map[string]string) map[string]string {
	if metadata == nil {
		metadata = map[string]string{}
	}
	metadata[SSEMultipart] = ""
	return metadata
}
136199
func FromMap(m map[string]interface{}, current string, namespace *[]string) error {
	return FromCompositeObject(m, current, namespace,
		InspectNilPointers(AlwaysFalse),
		InspectEmptyContainers(AlwaysFalse),
		ExportJsonFieldNames(AlwaysFalse))
}
1366461
func ParseMap(raw []string) Map {
	m := make(Map, len(raw))
	for _, t := range raw {
		m.Add(Parse(t))
	}
	return m
}
437776
func (v ElementBuildingVisitor) createMapValues(
	schemaFn schemaFn,
	meta apply.FieldMetaImpl,
	data apply.MapElementData) (map[string]apply.Element, error) {

	// Collate each key in the map
	values := map[string]apply.Element{}
	for _, key := range keysUnion(data.GetRecordedMap(), data.GetLocalMap(), data.GetRemoteMap()) {
		combined := apply.RawElementData{}
		if recorded, recordedSet := nilSafeLookup(key, data.GetRecordedMap()); recordedSet {
			combined.SetRecorded(recorded)
		}
		if local, localSet := nilSafeLookup(key, data.GetLocalMap()); localSet {
			combined.SetLocal(local)
		}
		if remote, remoteSet := nilSafeLookup(key, data.GetRemoteMap()); remoteSet {
			combined.SetRemote(remote)
		}

		// Create an item for the field
		field, err := v.getItem(schemaFn(key), key, combined)
		if err != nil {
			return nil, err
		}

		// Build the element for this field
		element, err := field.CreateElement(v)
		if err != nil {
			return nil, err
		}

		// Add the field element to the map
		values[key] = element
	}
	return values, nil
}
778398
func NestedMap(obj map[string]interface{}, fields ...string) (map[string]interface{}, bool, error) {
	m, found, err := nestedMapNoCopy(obj, fields...)
	if !found || err != nil {
		return nil, found, err
	}
	return runtime.DeepCopyJSON(m), true, nil
}
782743
func convertMap(datum interface{}) (map[string]interface{}, error) {
	mapValues, ok := datum.(map[string]interface{})
	if ok {
		return mapValues, nil
	}
	// NOTE: When given a map of any other type, zip values to items as a
	// convenience to client.
	v := reflect.ValueOf(datum)
	if v.Kind() != reflect.Map {
		return nil, fmt.Errorf("cannot create map[string]interface{}: expected map[string]...; received: %T", datum)
	}
	// NOTE: Two better alternatives to the current algorithm are:
	//   (1) mutate the reflection tuple underneath to convert the
	//       map[string]int, for example, to map[string]interface{}, with
	//       O(1) complexity.
	//   (2) use copy builtin to zip the data items over with O(n) complexity,
	//       but more efficient than what's below.
	mapValues = make(map[string]interface{}, v.Len())
	for _, key := range v.MapKeys() {
		k, ok := key.Interface().(string)
		if !ok {
			// bail when map key type is not string
			return nil, fmt.Errorf("cannot create map[string]interface{}: expected map[string]...; received: %T", datum)
		}
		mapValues[string(k)] = v.MapIndex(key).Interface()
	}
	return mapValues, nil
}
1167099
func KeysOfMap(m map[string]string) []string {
	keys := make(sort.StringSlice, len(m))
	i := 0
	for key, _ := range m {
		keys[i] = key
		i++
	}

	keys.Sort()
	return []string(keys)
}
618377
func CreateFrom(stringDate string) (*Carbon, error) {
	var carbon = Now()
	var err error
	var tm time.Time
	for _, format := range TimeFormats {
		tm, err = time.Parse(format, stringDate)
		if err == nil {
			carbon.Time = tm
			break
		}
	}

	return carbon, err
}
1116817
func (t *Type) createTypeFromPropItems(name string, apiDef *APIDefinition) {
	p := t.Properties[name]

	// propMap is this properties as map
	propMap, ok := p.(map[interface{}]interface{})
	if !ok {
		return
	}

	// only process the array
	tip, ok := propMap["type"]
	if !ok || tip != "array" {
		return
	}

	// only process if it has 'items' field
	itemsIf, ok := propMap["items"]
	if !ok {
		return
	}

	// check it's validity
	items, ok := itemsIf.(map[interface{}]interface{})
	if !ok {
		return
	}

	// to define new type, it needs to have 'properties' field
	props, ok := items["properties"].(map[interface{}]interface{})
	if !ok { // doesn't define new type, no problem, we can simply return
		return
	}
	newName := t.Name + name + "Item"
	created := apiDef.createType(newName, tip, props)

	delete(items, "properties")
	items["type"] = newName
	propMap["items"] = items

	t.Properties[name] = propMap

	if created {
		createdType := apiDef.Types[newName]
		createdType.postProcess(newName, apiDef)
	}
}
1179474
func NewMap(name string) *Map {
	return &Map{
		Map: *bpf.NewMap(
			name,
			bpf.BPF_MAP_TYPE_LPM_TRIE,
			int(unsafe.Sizeof(Key{})),
			int(unsafe.Sizeof(RemoteEndpointInfo{})),
			MaxEntries,
			bpf.BPF_F_NO_PREALLOC, 0,
			func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
				k, v := Key{}, RemoteEndpointInfo{}

				if err := bpf.ConvertKeyValue(key, value, &k, &v); err != nil {
					return nil, nil, err
				}
				return &k, &v, nil
			},
		).WithCache(),
		deleteSupport: true,
	}
}
962247
func (r *RawConfig) RawMap() map[string]interface{} {
	r.lock.Lock()
	defer r.lock.Unlock()

	m := make(map[string]interface{})
	for k, v := range r.Raw {
		m[k] = v
	}
	return m
}
317479
func MappingFuncFor(context ...map[string]string) func(string) string {
	return func(input string) string {
		for _, vars := range context {
			val, ok := vars[input]
			if ok {
				return val
			}
		}

		return syntaxWrap(input)
	}
}