// NewKeyStringValueTree creates a new key/value tree with or without
// duplicate values for children and strings as values.
188399
func NewKeyStringValueTree(k, v string, duplicates bool) KeyStringValueTree {
	return &keyStringValueTree{
		container: newNodeContainer(keyValue{k, v}, duplicates),
	}
}
451763
func newNodeValue(value interface{}) *node {
	n := newNode()
	n.value = value
	n.children = nil
	return n
}
456585
func (p *parser) splitKeyValuePair(s string) (key, value string, hasValue bool) {
	parts := strings.SplitN(s, "=", 2)
	switch len(parts) {
	case 1:
		key = s
	case 2:
		key = parts[0]
		value = parts[1]
		hasValue = true
	}
	return
}
769242
func NewKeyWrapEncrypt(alg jwa.KeyEncryptionAlgorithm, sharedkey []byte) (KeyWrapEncrypt, error) {
	return KeyWrapEncrypt{
		alg:       alg,
		sharedkey: sharedkey,
	}, nil
}
46020
func (kv KeyValue) String() string {
	return fmt.Sprintf("%s = %v", kv.Key, kv.Value)
}
1347476
func GetStringMapValue(mapVal, keyVal interface{}) (interface{}, error) {
	key, ok := keyVal.(string)
	if !ok {
		return nil, trace.BadParameter("only string keys are supported")
	}
	switch m := mapVal.(type) {
	case map[string][]string:
		if len(m) == 0 {
			// to return nil with a proper type
			var n []string
			return n, nil
		}
		return m[key], nil
	case map[string]string:
		if len(m) == 0 {
			return "", nil
		}
		return m[key], nil
	default:
		return nil, trace.BadParameter("type %T is not supported", m)
	}
}
591489
func GetStringValue(ctx context.Context, key interface{}) (value string) {
	if valuev, ok := ctx.Value(key).(string); ok {
		value = valuev
	}
	return value
}
412785
func NewKeyring() *Keyring {
	return &Keyring{
		encKeys: make(map[PublicKey]SecretKey),
		sigKeys: make(map[SigningPublicKey]SigningSecretKey),
	}
}
896941
func expandKeyValuePairs(keyValuePairs []interface{}) string {
	kvPairs := make([]string, 0, len(keyValuePairs)/2)

	// Just ignore the last dangling kv if odd #, cuz bug.
	for i, kv := range keyValuePairs {
		if i%2 == 1 {
			kvPairs = append(kvPairs, fmt.Sprintf("%v='%v'", keyValuePairs[i-1], kv))
		}
	}

	return strings.Join(kvPairs, " ")
}
707786
func NewFieldKey(obj map[string]interface{}, field string) FieldKey {
	return FieldKey{object: reflect.ValueOf(obj), field: field}
}
960046
func keyValueArgsToKeys(kvs ...interface{}) []string {
	keys := []string{}
	ok := true
	for _, k := range kvs {
		if ok {
			key := string(valueToBytes(k))
			keys = append(keys, key)
		}
		ok = !ok
	}
	return keys
}
825304
func (kvs KeyValues) String() string {
	kvss := []string{}
	for _, kv := range kvs {
		kvss = append(kvss, kv.String())
	}
	return fmt.Sprintf("[%s]", strings.Join(kvss, " / "))
}
697465
func MapKeyValues(keyvals []interface{}, fn func(interface{}, interface{}) (interface{}, interface{})) []interface{} {
	mappedKeyvals := make([]interface{}, len(keyvals))
	for i := 0; i < 2*(len(keyvals)/2); i += 2 {
		key := keyvals[i]
		val := keyvals[i+1]
		mappedKeyvals[i], mappedKeyvals[i+1] = fn(key, val)
	}
	return mappedKeyvals
}
6098
func getKeyVal(s string) (key, value string) {
	p := strings.SplitN(s, keySep, 2)
	return p[0], icsReplacer.Replace(p[1])
}
1261282
func NewKeyring() *Keyring {
	k := &Keyring{
		keys:       make(map[uint32]*Key),
		activeTerm: 0,
	}
	return k
}
367969
func NewKeyValuesStrings(key string, values ...string) KeyValues {
	iv := make([]interface{}, len(values))
	for i := 0; i < len(values); i++ {
		iv[i] = values[i]
	}
	return KeyValues{Key: key, Values: iv}
}
718054
func parseKeyValue(keyvalue string) (string, string) {
	var key, val string

	split := strings.Split(keyvalue, "=")
	// Must be exactly 2 to get anything meaningful out of them
	if len(split) == 2 {
		key = split[0]
		val = split[1]
	} else if len(split) == 1 {
		val = split[0]
	}

	return key, val
}