// Filter filters an array of strings.
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
}
1300660
func (offers Index) Filter(filter Filter) (result Index) {
	if sz := len(result); sz > 0 {
		result = make(Index, sz)
		for id, offer := range offers {
			if filter.Accept(offer) {
				result[id] = offer
			}
		}
	}
	return
}
721000
func filter(vs []NetworkDevice, f func(NetworkDevice) bool) []NetworkDevice {
	var vsf []NetworkDevice
	for _, v := range vs {
		if f(v) {
			vsf = append(vsf, v)
		}
	}
	return vsf
}
1176375
func (fm *filterManager) Filter() Filter {
	fm.fmLocker.RLock()
	defer fm.fmLocker.RUnlock()
	if len(fm.filters) == 0 {
		return nil
	}
	return fm.filters[0]
}
1004797
func (n *Notifications) Filter(oldStatus, newStatus buildbucketpb.Status) Notifications {
	notifications := n.GetNotifications()
	filtered := make([]*Notification, 0, len(notifications))
	for _, notification := range notifications {
		if notification.ShouldNotify(oldStatus, newStatus) {
			filtered = append(filtered, notification)
		}
	}
	return Notifications{Notifications: filtered}
}
1273164
func (l Logs) Filter(whiteset stringset.Set) Logs {
	newLogs := make(Logs)
	for repo, commits := range l {
		if whiteset.Has(repo) {
			newLogs[repo] = commits
		}
	}
	return newLogs
}
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
}
1110480
func (s *FieldSort) Filter(filter Query) *FieldSort {
	s.filter = filter
	return s
}
1129278
func (a *AdjacencyMatrixAggregation) Filters(name string, filter Query) *AdjacencyMatrixAggregation {
	a.filters[name] = filter
	return a
}
510914
func (b *BoolQueryBuilder) Filter() *FilterQueryBuilder {
	if b.filterQueryBuilder == nil {
		b.filterQueryBuilder = NewFilterQueryBuilder()
	}
	return b.filterQueryBuilder
}
673867
func (o querySet) Filter(expr string, args ...interface{}) QuerySeter {
	if o.cond == nil {
		o.cond = NewCondition()
	}
	o.cond = o.cond.And(expr, args...)
	return &o
}
1052735
func (d *Decoder) filter() {
	tok := d.next()
	if tok.t == tokenIdent && tok.value == "zoom" {
		compOp := d.comp()
		tok = d.next()
		if tok.t != tokenNumber {
			d.error(d.pos(tok), "zoom requires num, got %v", tok)
		}
		level, err := strconv.ParseInt(tok.value, 10, 64)
		if err != nil {
			d.error(d.pos(tok), "invalid zoom level %v: %v", tok, err)
		}
		if compOp == REGEX {
			d.error(d.pos(tok), "regular expressions are not allowed for zoom levels")
		}
		d.mss.addZoom(compOp, level)
		d.expect(tokenRBracket)
		return
	}

	var field string
	switch tok.t {
	case tokenString:
		field = tok.value[1 : len(tok.value)-1]
	case tokenIdent:
		field = tok.value
	default:
		d.error(d.pos(tok), "expected zoom or field name in filter, got '%s'", tok.value)
	}

	compOp := d.comp()
	tok = d.next()
	var value interface{}
	switch tok.t {
	case tokenString:
		value = tok.value[1 : len(tok.value)-1]
	case tokenNumber:
		value, _ = strconv.ParseFloat(tok.value, 64)
	case tokenIdent:
		if tok.value == "null" {
			value = nil
		} else {
			d.error(d.pos(tok), "unexpected value in filter '%s'", tok.value)
		}
	default:
		d.error(d.pos(tok), "unexpected value in filter '%s'", tok.value)
	}
	d.expect(tokenRBracket)
	d.mss.addFilter(field, compOp, value)
}
117909
func (n *NodeInfo) Filter(pod *v1.Pod) bool {
	if pod.Spec.NodeName != n.node.Name {
		return true
	}
	for _, p := range n.pods {
		if p.Name == pod.Name && p.Namespace == pod.Namespace {
			return true
		}
	}
	return false
}
686508
func Filters(f ...Filter) Modifier {
	return func(r *http.Request) error {
		for _, filter := range f {
			filter(r)
		}
		return nil // Or should filter return err?
	}
}
552896
func (s *NestedSort) Filter(filter Query) *NestedSort {
	s.filter = filter
	return s
}
908224
func (s Shrink) Filter(condition func(interface{}) bool) Shrink {
	if condition == nil {
		return s
	}
	return func() (interface{}, bool) {
		value, ok := s()
		for ok && !condition(value) {
			value, ok = s()
		}
		return value, ok
	}
}
372647
func Filter(arr interface{}, predicate interface{}) interface{} {
	if !IsIteratee(arr) {
		panic("First parameter must be an iteratee")
	}

	if !IsFunction(predicate, 1, 1) {
		panic("Second argument must be function")
	}

	funcValue := reflect.ValueOf(predicate)

	funcType := funcValue.Type()

	if funcType.Out(0).Kind() != reflect.Bool {
		panic("Return argument should be a boolean")
	}

	arrValue := reflect.ValueOf(arr)

	arrType := arrValue.Type()

	// Get slice type corresponding to array type
	resultSliceType := reflect.SliceOf(arrType.Elem())

	// MakeSlice takes a slice kind type, and makes a slice.
	resultSlice := reflect.MakeSlice(resultSliceType, 0, 0)

	for i := 0; i < arrValue.Len(); i++ {
		elem := arrValue.Index(i)

		result := funcValue.Call([]reflect.Value{elem})[0].Interface().(bool)

		if result {
			resultSlice = reflect.Append(resultSlice, elem)
		}
	}

	return resultSlice.Interface()
}