// removeElementFromStringSlice removes elem from list and returns
// the new slice.
979996
func removeElementFromStringSlice(list []string, elem string) []string {
	for i, e := range list {
		if e == elem {
			return append(list[:i], list[i+1:]...)
		}
	}
	return list
}
744657
func StringToIntSlice(s, sep string) []int {
	if s == "" {
		return nil
	}

	fields := strings.Split(s, sep)
	slice := make([]int, len(fields))
	for i, f := range fields {
		slice[i] = ToInt(f)
	}
	return slice
}
681223
func (t ListType) ConvertToStringSlice(value interface{}) ([]string, error) {
	if value == nil {
		return []string{}, nil
	}
	valueList, err := ConvertList(func(fieldType FieldType, value interface{}) (interface{}, error) {
		return fieldType.ConvertToStringSlice(value)
	}, t.ComponentType, value)
	if err != nil {
		return nil, errs.Wrapf(err, "failed to convert list type to string slice")
	}
	if (len(valueList)) == 0 {
		return []string{}, nil
	}
	buffer := make([]string, len(valueList))
	for i := range valueList {
		strValueList := valueList[i].([]string)
		if len(strValueList) != 1 {
			return nil, errs.Errorf("string conversion of base type did not return exactly one value")
		}
		buffer[i] = strValueList[0]
	}
	return buffer, nil
}
1027484
func (t SimpleType) ConvertToStringSlice(value interface{}) ([]string, error) {
	if value == nil {
		// if a value is nil, we return empty string.
		return []string{""}, nil
	}
	valueType := reflect.TypeOf(value)
	switch t.GetKind() {
	case KindString, KindUser, KindIteration, KindArea, KindLabel, KindBoardColumn:
		if valueType.Kind() != reflect.String {
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s", value, "string", valueType.Name())
		}
		return []string{value.(string)}, nil
	case KindRemoteTracker:
		v, err := AnyToUUID(value)
		if err != nil {
			return nil, err
		}
		return []string{v.String()}, nil
	case KindURL:
		if valueType.Kind() == reflect.String && govalidator.IsURL(value.(string)) {
			return []string{value.(string)}, nil
		}
		return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %q", value, "URL", valueType.Name())
	case KindFloat:
		if valueType.Kind() != reflect.Float64 {
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %q", value, "float64", valueType.Name())
		}
		fval, ok := value.(float64)
		if !ok {
			return nil, errs.Errorf("failed to cast value %+v (%[1]T) to float64", value)
		}
		return []string{strconv.FormatFloat(fval, 'f', 6, 64)}, nil
	case KindInteger:
		// NOTE(kwk): This will change soon to be more consistent.
		switch valueType.Kind() {
		case reflect.Int:
			ival, ok := value.(int)
			if !ok {
				return nil, errs.Errorf("failed to cast value %+v (%[1]T) to int", value)
			}
			return []string{strconv.Itoa(ival)}, nil
		case reflect.Int64:
			ival, ok := value.(int64)
			if !ok {
				return nil, errs.Errorf("failed to cast value %+v (%[1]T) to int64", value)
			}
			return []string{strconv.FormatInt((ival), 10)}, nil
		case reflect.Float64:
			fval, ok := value.(float64)
			if !ok {
				return nil, errs.Errorf("failed to cast value %+v (%[1]T) to float64", value)
			}
			if fval != math.Trunc(fval) {
				return nil, errs.Errorf("float64 value %+v (%[1]T) has digits after the decimal point and therefore cannot be represented by an integer", value)
			}
			return []string{strconv.FormatFloat(fval, 'f', 0, 64)}, nil
		default:
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s ", value, "int or float", valueType.Name())
		}
	case KindInstant:
		if valueType.Kind() != timeType.Kind() {
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s", value, "time.Time", valueType.Name())
		}
		timeVal, ok := value.(time.Time)
		if !ok {
			return nil, errs.Errorf(`value should be of type "time.Time" but is of type "%[1]T": %[1]+v`, value)
		}
		return []string{timeVal.Format(time.RFC3339)}, nil
	case KindBoolean:
		if valueType.Kind() != reflect.Bool {
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s", value, "boolean", valueType.Name())
		}
		if value.(bool) {
			return []string{"true"}, nil
		}
		return []string{"false"}, nil
	case KindMarkup:
		// 'markup' is just a string in the API layer for now:
		// it corresponds to the MarkupContent.Content field. The MarkupContent.Markup is set to the default value
		switch value.(type) {
		case rendering.MarkupContent:
			markupContent := value.(rendering.MarkupContent)
			if !rendering.IsMarkupSupported(markupContent.Markup) {
				return nil, errs.Errorf("value %v (%[1]T) has no valid markup type %s", value, markupContent.Markup)
			}
			return []string{markupContent.Content}, nil
		case map[string]interface{}:
			markupContent := rendering.NewMarkupContentFromValue(value)
			if !rendering.IsMarkupSupported(markupContent.Markup) {
				return nil, errs.Errorf("value %v (%[1]T) has no valid markup type %s", value, markupContent.Markup)
			}
			return []string{markupContent.Content}, nil
		default:
			return nil, errs.Errorf("value %v (%[1]T) should be rendering.MarkupContent, but is %s", value, valueType)
		}
	case KindCodebase:
		switch value.(type) {
		case codebase.Content:
			cb := value.(codebase.Content)
			if err := cb.IsValid(); err != nil {
				return nil, errs.Wrapf(err, "value %v (%[1]T) is invalid %s", value, cb)
			}
			return []string{cb.Repository + "#" + cb.Branch + "#" + cb.FileName + ":" + strconv.Itoa(cb.LineNumber)}, nil
		default:
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s", value, "CodebaseContent", valueType)
		}
	// Note: the KindEnum and KindList cases are omitted as they are not used. We may want to remove them
	// from ConvertToModel() as well.
	default:
		return nil, errs.Errorf("unexpected type constant: '%s'", t.GetKind())
	}
}
1085008
func SetNestedStringSlice(obj map[string]interface{}, value []string, fields ...string) error {
	m := make([]interface{}, 0, len(value)) // convert []string into []interface{}
	for _, v := range value {
		m = append(m, v)
	}
	return setNestedFieldNoCopy(obj, m, fields...)
}
940878
func ReverseStringSlice(s []string) []string {
	r := make([]string, len(s))
	for i := range s {
		r[len(r)-1-i] = s[i]
	}
	return r
}
468095
func removeFromStmtList(node ast.Node, list []ast.Stmt) bool {
	for i, s := range list {
		if s == node {
			for ; i < len(list)-1; i++ {
				list[i] = list[i+1]
			}
			list[len(list)-1] = &ast.EmptyStmt{}
			return true
		}
	}

	return false
}
1354733
func Uint32Slice(val, sep string) ([]uint32, error) {
	s := strings.Split(val, sep)
	values := make([]uint32, len(s))
	for i, v := range s {
		value, err := Uint32(v)
		if err != nil {
			return values, err
		}
		values[i] = value
	}
	return values, nil
}
103260
func NewStringSetFromSlice(s []string) StringSet {
	a := NewStringSetWithCapacity(len(s))
	for _, item := range s {
		a.Add(item)
	}
	return a
}
988329
func StringSlice(v []string) []*string {
	out := make([]*string, len(v))
	for i := range v {
		out[i] = &v[i]
	}
	return out
}
955283
func newElementFromStr(s string, index index) (*element, error) {
	hash, err := hashFromString(s)
	if err != nil {
		return nil, err
	}

	return &element{
		index: index,
		hash:  *hash,
	}, nil
}
693039
func stringFromInterface(val interface{}) (string, error) {
	switch val.(type) {
	case string:
		return val.(string), nil
	}
	return "", fmt.Errorf("Expected string value for String, got \"%v\"\n", val)
}
315766
func StringInSlice(valid []string, ignoreCase bool) schema.SchemaValidateFunc {
	return func(i interface{}, k string) (s []string, es []error) {
		v, ok := i.(string)
		if !ok {
			es = append(es, fmt.Errorf("expected type of %s to be string", k))
			return
		}

		for _, str := range valid {
			if v == str || (ignoreCase && strings.ToLower(v) == strings.ToLower(str)) {
				return
			}
		}

		es = append(es, fmt.Errorf("expected %s to be one of %v, got %s", k, valid, v))
		return
	}
}
121563
func indexOfStringSlice(strings []string, s string) int {
	for i, b := range strings {
		if b == s {
			return i
		}
	}
	return -1
}
965090
func StringToInt32Slice(s, sep string) []int32 {
	if s == "" {
		return nil
	}

	fields := strings.Split(s, sep)
	slice := make([]int32, len(fields))
	for i, f := range fields {
		slice[i] = ToInt32(f)
	}
	return slice
}
94061
func (d Data) GetStringsSplit(key string, delim string) []string {
	if !d.KeyExists(key) || len(d.Values[key]) == 0 {
		return nil
	}
	return strings.Split(d.Values[key][0], delim)
}
826019
func (cs *CoinSet) removeElement(e *list.Element) Coin {
	c := e.Value.(Coin)
	cs.coinList.Remove(e)
	cs.totalValue -= c.Value()
	cs.totalValueAge -= c.ValueAge()
	return c
}