// Slice is not meant to be used externally. It's a bridge function
// for the template functions. See collections.Slice.
344898
func (p PageGroup) Slice(in interface{}) (interface{}, error) {
	switch items := in.(type) {
	case PageGroup:
		return items, nil
	case []interface{}:
		groups := make(PagesGroup, len(items))
		for i, v := range items {
			g, ok := v.(PageGroup)
			if !ok {
				return nil, fmt.Errorf("type %T is not a PageGroup", v)
			}
			groups[i] = g
		}
		return groups, nil
	default:
		return nil, fmt.Errorf("invalid slice type %T", items)
	}
}
1325010
func (s *ScrollService) Slice(sliceQuery Query) *ScrollService {
	s.ss = s.ss.Slice(sliceQuery)
	return s
}
866158
func (s *Shuffler) Slice(slice Interface) {
	rv := reflect.ValueOf(slice)
	swap := reflect.Swapper(slice)
	n := rv.Len()
	for i := n - 1; i >= 0; i-- {
		j := (*rand.Rand)(s).Intn(i + 1)
		swap(i, j)
	}
}
1079324
func sliceToFSType(s []string) []securityv1.FSType {
	fsTypes := []securityv1.FSType{}
	for _, v := range s {
		fsTypes = append(fsTypes, securityv1.FSType(v))
	}
	return fsTypes
}
385295
func Slice(elements ...interface{}) AnyIfType {
	return AnyIf(func(argument interface{}) bool {
		var v = reflect.ValueOf(argument)

		if v.Kind() != reflect.Slice {
			return false
		}

		var el, al = len(elements), v.Len()

		if el == 0 {
			return al == 0
		}

		if elements[el-1] == Rest {
			el--

			if al < el {
				return false
			}
		} else if al != el {
			return false
		}

		for i := 0; i < el; i++ {
			if !match(v.Index(i).Interface(), elements[i]) {
				return false
			}
		}

		return true
	})
}
363527
func sliceKind(val reflect.Value) reflect.Kind {
	switch val.Type().Elem().Kind() {
	case reflect.Ptr:
		return ptrKind(val.Type().Elem())
	}
	return val.Type().Elem().Kind()
}
1034451
func (r *AMD64Registers) Slice(floatingPoint bool) []proc.Register {
	var regs = []struct {
		k string
		v uint64
	}{
		{"Rip", r.rip},
		{"Rsp", r.rsp},
		{"Rax", r.rax},
		{"Rbx", r.rbx},
		{"Rcx", r.rcx},
		{"Rdx", r.rdx},
		{"Rdi", r.rdi},
		{"Rsi", r.rsi},
		{"Rbp", r.rbp},
		{"R8", r.r8},
		{"R9", r.r9},
		{"R10", r.r10},
		{"R11", r.r11},
		{"R12", r.r12},
		{"R13", r.r13},
		{"R14", r.r14},
		{"R15", r.r15},
		{"Eflags", r.eflags},
		{"Cs", r.cs},
		{"Fs", r.fs},
		{"Gs", r.gs},
		{"TLS", r.tls},
	}
	outlen := len(regs)
	if r.fltSave != nil && floatingPoint {
		outlen += 6 + 8 + 2 + 16
	}
	out := make([]proc.Register, 0, outlen)
	for _, reg := range regs {
		if reg.k == "Eflags" {
			out = proc.AppendEflagReg(out, reg.k, reg.v)
		} else {
			out = proc.AppendQwordReg(out, reg.k, reg.v)
		}
	}
	if r.fltSave != nil && floatingPoint {
		out = proc.AppendWordReg(out, "CW", r.fltSave.ControlWord)
		out = proc.AppendWordReg(out, "SW", r.fltSave.StatusWord)
		out = proc.AppendWordReg(out, "TW", uint16(r.fltSave.TagWord))
		out = proc.AppendWordReg(out, "FOP", r.fltSave.ErrorOpcode)
		out = proc.AppendQwordReg(out, "FIP", uint64(r.fltSave.ErrorSelector)<<32|uint64(r.fltSave.ErrorOffset))
		out = proc.AppendQwordReg(out, "FDP", uint64(r.fltSave.DataSelector)<<32|uint64(r.fltSave.DataOffset))

		for i := range r.fltSave.FloatRegisters {
			out = proc.AppendX87Reg(out, i, uint16(r.fltSave.FloatRegisters[i].High), r.fltSave.FloatRegisters[i].Low)
		}

		out = proc.AppendMxcsrReg(out, "MXCSR", uint64(r.fltSave.MxCsr))
		out = proc.AppendDwordReg(out, "MXCSR_MASK", r.fltSave.MxCsr_Mask)

		for i := 0; i < len(r.fltSave.XmmRegisters); i += 16 {
			out = proc.AppendSSEReg(out, fmt.Sprintf("XMM%d", i/16), r.fltSave.XmmRegisters[i:i+16])
		}
	}
	return out
}
10335
func SliceRemove(slice []interface{}, start int, args ...int) []interface{} {
	var end int
	if len(args) == 0 {
		end = start + 1
	} else {
		end = args[0]
	}
	if end > len(slice)-1 {
		return slice[:start]
	}
	return append(slice[:start], slice[end:]...)
}
1277860
func (p *Partial) SliceOfLength(length int) (a []*Partial, err error) {
	err = p.Unmarshal(&a)
	if err != nil {
		return
	}

	if len(a) != length {
		err = errors.New("Invalid array length")
	}

	return
}
61421
func PropSlice(slice string) Property {
	return Property{
		Name:  "Slice",
		Value: dbus.MakeVariant(slice),
	}
}
944124
func sliceParser(rd *proto.Reader, n int64) (interface{}, error) {
	vals := make([]interface{}, 0, n)
	for i := int64(0); i < n; i++ {
		v, err := rd.ReadReply(sliceParser)
		if err != nil {
			if err == Nil {
				vals = append(vals, nil)
				continue
			}
			if err, ok := err.(proto.RedisError); ok {
				vals = append(vals, err)
				continue
			}
			return nil, err
		}

		switch v := v.(type) {
		case string:
			vals = append(vals, v)
		default:
			vals = append(vals, v)
		}
	}
	return vals, nil
}
364012
func (p WeightedPage) Slice(in interface{}) (interface{}, error) {
	switch items := in.(type) {
	case WeightedPages:
		return items, nil
	case []interface{}:
		weighted := make(WeightedPages, len(items))
		for i, v := range items {
			g, ok := v.(WeightedPage)
			if !ok {
				return nil, fmt.Errorf("type %T is not a WeightedPage", v)
			}
			weighted[i] = g
		}
		return weighted, nil
	default:
		return nil, fmt.Errorf("invalid slice type %T", items)
	}
}
828903
func RemoveFromSlice(slice []string, values ...string) []string {
	output := make([]string, 0, len(slice))

	remove := make(map[string]bool)
	for _, value := range values {
		remove[value] = true
	}

	for _, s := range slice {
		_, ok := remove[s]
		if ok {
			continue
		}
		output = append(output, s)
	}

	return output
}
486109
func decodeSlice(elemType reflect.Type, slice reflect.Value, input map[string]interface{}) error {
	var v reflect.Value
	if elemType.Kind() == reflect.Ptr {
		v = reflect.New(elemType.Elem())
	} else {
		v = reflect.New(elemType)
	}

	if !v.CanInterface() {
		return fmt.Errorf("can't interface %#v", v)
	}

	if err := decodeMap(input, v.Interface()); err != nil {
		return err
	}

	if elemType.Kind() == reflect.Struct {
		v = v.Elem()
	}
	slice.Set(reflect.Append(slice, v))

	return nil
}
422652
func (p *Prompt) Slice(q string, slice []string, def ...int) (selected []int, err error) {
	w := &w{}
	w.println(p.output, colors.Default, q)
	for i, v := range slice {
		c := colors.Default
		if inIntSlice(i, def) {
			c = p.defaultColor
		}
		w.printf(p.output, c, "（%d）", i)
		w.printf(p.output, colors.Default, "%s\n", v)
	}
	w.print(p.output, colors.Default, "请输入你的选择项，多项请用半角逗号（,）分隔：")

	val := w.read(p)
	if w.err != nil {
		return nil, w.err
	}

	if val == "" {
		return def, nil
	}

	for _, v := range strings.Split(val, ",") {
		vv, err := strconv.Atoi(v)
		if err != nil {
			return nil, err
		}
		selected = append(selected, vv)
	}
	return selected, nil
}
1016562
func (commonResource) Slice(in interface{}) (interface{}, error) {
	switch items := in.(type) {
	case resource.Resources:
		return items, nil
	case []interface{}:
		groups := make(resource.Resources, len(items))
		for i, v := range items {
			g, ok := v.(resource.Resource)
			if !ok {
				return nil, fmt.Errorf("type %T is not a Resource", v)
			}
			groups[i] = g
		}
		return groups, nil
	default:
		return nil, fmt.Errorf("invalid slice type %T", items)
	}
}
1138523
func (kf *KunstructuredFactoryImpl) SliceFromBytes(
	in []byte) ([]ifc.Kunstructured, error) {
	decoder := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(in), 1024)
	var result []ifc.Kunstructured
	var err error
	for err == nil || isEmptyYamlError(err) {
		var out unstructured.Unstructured
		err = decoder.Decode(&out)
		if err == nil {
			if len(out.Object) == 0 {
				continue
			}
			err = kf.validate(out)
			if err != nil {
				return nil, err
			}
			result = append(result, &UnstructAdapter{Unstructured: out})
		}
	}
	if err != io.EOF {
		return nil, err
	}
	return result, nil
}