// filterFunc is used to compose a complete predictor that filters an array
// of strings as per the filter function.
196922
func (p *Predict) filterFunc(f func() []string) complete.Predictor {
	return complete.PredictFunc(func(args complete.Args) []string {
		if p.hasPathArg(args.All) {
			return nil
		}

		client := p.Client()
		if client == nil {
			return nil
		}

		return p.filter(f(), args.Last)
	})
}
99345
func (c *Criterion) MatchFunc(match MatchFunc) *Query {
	if c.query.currentField == Key {
		panic("Match func cannot be used against Keys, as the Key type is unknown at runtime, and there is no value compare against")
	}

	return c.op(fn, match)
}
651953
func FilterString(s []string, cb func(s string) bool) []string {
	results := []string{}

	for _, i := range s {
		result := cb(i)

		if result {
			results = append(results, i)
		}
	}

	return results
}
160023
func FiltersFromArgs(filterVals []value.Value) []string {
	filters := make([]string, 0, len(filterVals))
	for _, fv := range filterVals {
		switch fv := fv.(type) {
		case value.Slice:
			for _, fv := range fv.SliceValue() {
				matchKey := fv.ToString()
				if strings.Contains(matchKey, "%") {
					matchKey = strings.Replace(matchKey, "%", "*", -1)
				}
				filters = append(filters, matchKey)
			}
		case value.StringValue:
			matchKey := fv.ToString()
			if strings.Contains(matchKey, "%") {
				matchKey = strings.Replace(matchKey, "%", "*", -1)
			}
			filters = append(filters, matchKey)
		}
	}
	return filters
}
1087096
func FilterHasSuffix(completions []Suggest, sub string, ignoreCase bool) []Suggest {
	return filterSuggestions(completions, sub, ignoreCase, strings.HasSuffix)
}
305625
func (set StringSet) ApplyFunc(applyFn func(string) string) StringSet {
	nset := NewStringSet()
	for k := range set {
		nset.Add(applyFn(k))
	}
	return nset
}
1302229
func FilterCommits(commits []*Commit, filterFunc CommitFilterFunc) []*Commit {
	cs := make([]*Commit, 0, len(commits))
	for _, commit := range commits {
		if filterFunc(commit) {
			cs = append(cs, commit)
		}
	}
	return cs
}
625321
func (p *Predict) filter(list []string, prefix string) []string {
	var predictions []string
	for _, item := range list {
		if strings.HasPrefix(item, prefix) {
			predictions = append(predictions, item)
		}
	}
	return predictions
}
858343
func (n *EvalSequence) Filter(fn EvalNodeFilterFunc) {
	for i, node := range n.Nodes {
		n.Nodes[i] = fn(node)
	}
}
1122983
func (o *Options) validateFunc() ValidateFunc {
	if o.ValidateFunc == nil {
		return defaultValidateFunc
	}

	return o.ValidateFunc
}
1314114
func filterFromCache(m map[string]string) bool {
	c, err := getCacheControlOpts(m)
	if err != nil {
		return false
	}
	return c.exclude
}
436157
func (s strings) Filter(in []string, keep func(item string) bool) []string {
	var out []string
	for _, item := range in {
		if keep(item) {
			out = append(out, item)
		}
	}

	return out
}
835096
func filterString(in string) string {
	var (
		rs         = []rune(in)
		flag, prev rune
		psn        int
	)
	for k, r := range rs {
		// fmt.Println(string(r), " ", r)
		switch r {
		case '"':
			if flag == '\'' && prev != '\\' {
				rs[k] = 0 // bookmark for replace
			}
			if flag == 0 {
				flag = '"'
				psn = k
			} else if r == flag && prev != '\\' {
				flag = 0
			}
		case '\'':
			if flag == 0 {
				flag = '\''
				psn = k
			} else if r == flag && prev != '\\' {
				// if k-(psn+1) != 1 {
				rs[psn] = '"'
				rs[k] = '"'
				// }
				flag = 0
			}
		case '`':
			if flag == 0 {
				flag = '`'
				psn = k
			} else if r == flag {
				flag = 0
			}
		}
		prev = r
	}
	filterPlus(rs)
	filterJsEsc(rs)
	out := strings.Replace(string(rs), string(rune(0)), `\"`, -1)
	out = strings.Replace(out, string(rune(1)), ``, -1)
	out = strings.Replace(out, string([]rune{2, 2}), "`+", -1)
	out = strings.Replace(out, string(rune(3)), "+`", -1)
	return out
}
632545
func (g *genExpansion) Filter(c *generator.Context, t *types.Type) bool {
	return len(g.types) == 0 || t == g.types[0]
}
589496
func Filter(src string, filter func(int, []byte) error) error {
	return Read(src, func(fd *os.File) (err error) {
		return io2.FilterRead(fd, filter)
	})
}
29501
func (w *WebService) Filter(filter FilterFunction) *WebService {
	w.filters = append(w.filters, filter)
	return w
}
687830
func (s *Server) UseFunc(filters ...FilterFunc) {
	for _, f := range filters {
		s.filters = append(s.filters, f)
	}
}