// listFilterIfs returns a map of interfaces based on the given filter.
// The filter should take a link and, if found, return the index of that
// interface, if not found return -1.
978258
func listFilterIfs(filter func(netlink.Link) int) (map[int]netlink.Link, error) {
	ifs, err := netlink.LinkList()
	if err != nil {
		return nil, err
	}
	vethLXCIdxs := map[int]netlink.Link{}
	for _, intf := range ifs {
		if idx := filter(intf); idx != -1 {
			vethLXCIdxs[idx] = intf
		}
	}
	return vethLXCIdxs, nil
}
196048
func (c *Client) ListImages(filter *Filter) ([]Image, error) {
	var resp []Image
	req := request{
		method: client.GET,
		url:    apiImages,
		filter: filter,
		resp:   &resp,
	}
	if _, err := c.sendRequest(req); err != nil {
		return nil, errors.Newf(err, "failed to get list of images")
	}
	return resp, nil
}
473912
func (list *List) Filter(f func(string) bool) {
	if list.length == 0 {
		return
	}
	var start, current *ListItem
	length := 0
	tmp := list.first
	for i := 0; i < list.length; i++ {
		if f(tmp.Content) {
			if length == 0 {
				start = tmp
				current = tmp
			} else {
				current.Next = tmp
				current = tmp
			}
			length++
		}
		if tmp.Next != nil {
			tmp = tmp.Next
		} else {
			break
		}
	}
	list.first = start
	list.last = current
	list.length = length
}
226061
func (idx *CfIndex) FilterHeaderByBlockHash(h *chainhash.Hash,
	filterType wire.FilterType) ([]byte, error) {
	return idx.entryByBlockHash(cfHeaderKeys, filterType, h)
}
1243230
func (s *applicationOffers) filterOffers(
	in []applicationOfferDoc,
	filter crossmodel.ApplicationOfferFilter,
) ([]applicationOfferDoc, error) {

	out, err := s.filterOffersByEndpoint(in, filter.Endpoints)
	if err != nil {
		return nil, errors.Trace(err)
	}
	out, err = s.filterOffersByConnectedUser(out, filter.ConnectedUsers)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return s.filterOffersByAllowedConsumer(out, filter.AllowedConsumers)
}
1026071
func (s *applicationOffers) ListOffers(filters ...crossmodel.ApplicationOfferFilter) ([]crossmodel.ApplicationOffer, error) {
	applicationOffersCollection, closer := s.st.db().GetCollection(applicationOffersC)
	defer closer()

	var offerDocs []applicationOfferDoc
	if len(filters) == 0 {
		err := applicationOffersCollection.Find(nil).All(&offerDocs)
		if err != nil {
			return nil, errors.Trace(err)
		}
	}
	for _, filter := range filters {
		var mgoQuery bson.D
		elems := s.makeFilterTerm(filter)
		mgoQuery = append(mgoQuery, elems...)

		var docs []applicationOfferDoc
		err := applicationOffersCollection.Find(mgoQuery).All(&docs)
		if err != nil {
			return nil, errors.Trace(err)
		}

		docs, err = s.filterOffers(docs, filter)
		if err != nil {
			return nil, errors.Trace(err)
		}
		offerDocs = append(offerDocs, docs...)
	}
	sort.Sort(offerSlice(offerDocs))

	offers := make([]crossmodel.ApplicationOffer, len(offerDocs))
	for i, doc := range offerDocs {
		offer, err := s.makeApplicationOffer(doc)
		if err != nil {
			return nil, errors.Trace(err)
		}
		offers[i] = *offer
	}
	return offers, nil
}
914318
func (pm *Manager) List(pluginFilters filters.Args) ([]types.Plugin, error) {
	return nil, errNotSupported
}
73192
func (r *Containerd) ListContainers(filter string) ([]string, error) {
	return listCRIContainers(r.Runner, filter)
}
870702
func (r *Docker) ListContainers(filter string) ([]string, error) {
	content, err := r.Runner.CombinedOutput(fmt.Sprintf(`docker ps -a --filter="name=%s" --format="{{.ID}}"`, filter))
	if err != nil {
		return nil, err
	}
	var ids []string
	for _, line := range strings.Split(content, "\n") {
		if line != "" {
			ids = append(ids, line)
		}
	}
	return ids, nil
}
978830
func ListServices(filters []string) (services []Service, err error) {
	launchAgentDir := launchAgentDir()
	if _, derr := os.Stat(launchAgentDir); os.IsNotExist(derr) {
		return
	}
	files, err := ioutil.ReadDir(launchAgentDir)
	if err != nil {
		return
	}
	for _, f := range files {
		fileName := f.Name()
		suffix := ".plist"
		// We care about services that contain the filter word and end in .plist
		for _, filter := range filters {
			if strings.HasPrefix(fileName, filter) && strings.HasSuffix(fileName, suffix) {
				label := fileName[0 : len(fileName)-len(suffix)]
				service := NewService(label)
				services = append(services, service)
			}
		}
	}
	return
}
1131547
func (o *Gateway) MACFilterProfiles(info *bambou.FetchingInfo) (MACFilterProfilesList, *bambou.Error) {

	var list MACFilterProfilesList
	err := bambou.CurrentSession().FetchChildren(o, MACFilterProfileIdentity, &list, info)
	return list, err
}
387839
func (ms Mounts) Filter(f FilterFunc) Mounts {
	filtered := make([]*Mount, 0, len(ms))

	for _, m := range ms {
		if f(m) {
			filtered = append(filtered, m)
		}
	}

	return Mounts(filtered)
}
968941
func Filter(vs []string, f func(string) bool) []string {
	r := make([]string, 0, len(vs))
	for _, v := range vs {
		if f(v) {
			r = append(r, v)
		}
	}
	return r
}
723604
func (s *AffinityGroupService) ListAffinityGroups(p *ListAffinityGroupsParams) (*ListAffinityGroupsResponse, error) {
	resp, err := s.cs.newRequest("listAffinityGroups", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ListAffinityGroupsResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
256148
func (c *Client) ListOffers(filters ...crossmodel.ApplicationOfferFilter) ([]*crossmodel.ApplicationOfferDetails, error) {
	var paramsFilter params.OfferFilters
	for _, f := range filters {
		filterTerm := params.OfferFilter{
			OwnerName:           f.OwnerName,
			ModelName:           f.ModelName,
			OfferName:           f.OfferName,
			ApplicationName:     f.ApplicationName,
			Endpoints:           make([]params.EndpointFilterAttributes, len(f.Endpoints)),
			AllowedConsumerTags: make([]string, len(f.AllowedConsumers)),
			ConnectedUserTags:   make([]string, len(f.ConnectedUsers)),
		}
		for i, ep := range f.Endpoints {
			filterTerm.Endpoints[i].Name = ep.Name
			filterTerm.Endpoints[i].Interface = ep.Interface
			filterTerm.Endpoints[i].Role = ep.Role
		}
		for i, u := range f.AllowedConsumers {
			filterTerm.AllowedConsumerTags[i] = names.NewUserTag(u).String()
		}
		for i, u := range f.ConnectedUsers {
			filterTerm.ConnectedUserTags[i] = names.NewUserTag(u).String()
		}
		paramsFilter.Filters = append(paramsFilter.Filters, filterTerm)
	}

	offers := params.QueryApplicationOffersResults{}
	err := c.facade.FacadeCall("ListApplicationOffers", paramsFilter, &offers)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return convertOffersResultsToModel(offers.Results)
}
796250
func ListByFilters(skip int, filters ...Filter) (callinfos []CallInfo) {
	filters = append(FilterCommons, filters...)
	for {
		var callinfo CallInfo
		var ok bool
		skip++

		if callinfo, ok = retrieveCallInfo(skip); !ok {
			return
		}

		valid, stop := filterAll(callinfo, filters...)
		if valid {
			callinfos = append(callinfos, callinfo)
		}
		if stop {
			return
		}
	}
}
992969
func generateListFilterFromLabels(labels map[string]string) string {
	var filter string
	for k, v := range labels {
		filter = fmt.Sprintf("%s(labels.%s eq %s)", filter, k, v)
	}

	return filter
}