//Each iterates through all items in the collector
328918
func (c *SyncCollector) Each(fx StringEachfunc) {
	var state bool
	c.rw.RLock()
	for k, v := range c.c {
		if state {
			break
		}

		fx(v, k, func() {
			state = true
		})
	}
	c.rw.RUnlock()
}
607980
func (ListVirtualMachines) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListVirtualMachinesResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListVirtualMachinesResponse was expected, got %T", resp))
		return
	}

	for i := range items.VirtualMachine {
		if !callback(&items.VirtualMachine[i], nil) {
			break
		}
	}
}
309816
func (this Collection) FindAll(s interface{}) Collection {
    re := getRegexp(s)
    var result Collection
    for _, c := range this {
        result = append(result, c.FindAll(re)...)
    }

    return result
}
86663
func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool) {
	for i, val := range vals.Validators {
		stop := fn(i, val.Copy())
		if stop {
			break
		}
	}
}
920639
func (s *UsersStore) All(ctx context.Context) ([]chronograf.User, error) {
	var users []chronograf.User
	if err := s.client.db.View(func(tx *bolt.Tx) error {
		return tx.Bucket(UsersBucket).ForEach(func(k, v []byte) error {
			var user chronograf.User
			if err := internal.UnmarshalUser(v, &user); err != nil {
				return err
			}
			users = append(users, user)
			return nil
		})
	}); err != nil {
		return nil, err
	}

	return users, nil
}
688173
func (ListAsyncJobs) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListAsyncJobsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListAsyncJobsResponse was expected, got %T", resp))
		return
	}

	for i := range items.AsyncJob {
		if !callback(&items.AsyncJob[i], nil) {
			break
		}
	}
}
866596
func (h *sentPacketHistory) Iterate(cb func(*Packet) (cont bool, err error)) error {
	cont := true
	for el := h.packetList.Front(); cont && el != nil; el = el.Next() {
		var err error
		cont, err = cb(&el.Value)
		if err != nil {
			return err
		}
	}
	return nil
}
1114710
func (store *KapacitorStore) All(ctx context.Context) ([]chronograf.Server, error) {
	if store.Kapacitor != nil {
		return []chronograf.Server{*store.Kapacitor}, nil
	}
	return nil, nil
}
1341015
func (collection *Collection) Items() ([]Item, error) {
  val, err := collection.dbus.GetProperty("org.freedesktop.Secret.Collection.Items")
  if err != nil {
    return []Item{}, err
  }

  items := []Item{}
  for _, path := range val.Value().([]dbus.ObjectPath) {
    items = append(items, *NewItem(collection.conn, path))
  }

  return items, nil
}
928500
func (p *Pool) Each(f func(*Bytes)) {
	l := len(p.list)
	t := make([]*Bytes, l)
	defer func() {
		for i := 0; i < len(t); i++ {
			t[i].Release()
		}
	}()
	for i := 0; i < l; i++ {
		b := <-p.list
		t[i] = b
		f(b)
	}
}
1216871
func (ListAccounts) Each(resp interface{}, callback IterateItemFunc) {
	items, ok := resp.(*ListAccountsResponse)
	if !ok {
		callback(nil, fmt.Errorf("wrong type, ListAccountsResponse was expected, got %T", resp))
		return
	}

	for i := range items.Account {
		if !callback(&items.Account[i], nil) {
			break
		}
	}
}
1022057
func (s *SyncedSet) Items() (c chan interface{}) {
	c = make(chan interface{})
	go func() {
		s.RLock()
		defer s.RUnlock()
		defer close(c)
		for k := range s.set {
			c <- k
		}
	}()
	return c

}
105788
func (l *OptionsLoader) iterate(userConfig interface{}, current interface{}) (interface{}, error) {
	sort.Sort(l.templates)

	t := reflect.TypeOf(current).Elem()

	next := reflect.New(t).Interface()

	// Copy the current state before applying rules; they act as defaults
	reflectutils.JsonMergeStruct(next, current)

	for _, t := range l.templates {
		glog.V(2).Infof("executing template %s (tags=%s)", t.Name, t.Tags)

		var buffer bytes.Buffer
		err := t.Template.ExecuteTemplate(&buffer, t.Name, current)
		if err != nil {
			return nil, fmt.Errorf("error executing template %q: %v", t.Name, err)
		}

		yamlBytes := buffer.Bytes()

		jsonBytes, err := utils.YAMLToJSON(yamlBytes)
		if err != nil {
			// TODO: It would be nice if yaml returned us the line number here
			glog.Infof("error parsing yaml.  yaml follows:")
			for i, line := range strings.Split(string(yamlBytes), "\n") {
				fmt.Fprintf(os.Stderr, "%3d: %s\n", i, line)
			}
			return nil, fmt.Errorf("error parsing yaml %q: %v", t.Name, err)
		}

		err = json.Unmarshal(jsonBytes, next)
		if err != nil {
			return nil, fmt.Errorf("error parsing yaml (converted to JSON) %q: %v", t.Name, err)
		}
	}

	for _, t := range l.Builders {
		glog.V(2).Infof("executing builder %T", t)

		err := t.BuildOptions(next)
		if err != nil {
			return nil, err
		}
	}

	// Also copy the user-provided values after applying rules; they act as overrides now
	reflectutils.JsonMergeStruct(next, userConfig)

	return next, nil
}
1299137
func (b *BoltKeyspace) ForEach(each ItemHandler) error {
    return b.db.View(func(tx *bolt.Tx) error {
        b := tx.Bucket([]byte(b.name))
        return b.ForEach(each)
    })
}
42004
func (c *IterateChain) Each(fnc func(Value)) error {
	c.start()
	defer c.end()
	done := c.ctx.Done()

	for c.next() {
		select {
		case <-done:
			return c.ctx.Err()
		default:
		}
		fnc(c.it.Result())
		for c.nextPath() {
			select {
			case <-done:
				return c.ctx.Err()
			default:
			}
			fnc(c.it.Result())
		}
	}
	return c.it.Err()
}
1019847
func EachListItem(obj runtime.Object, fn func(runtime.Object) error) error {
	if unstructured, ok := obj.(runtime.Unstructured); ok {
		return unstructured.EachListItem(fn)
	}
	// TODO: Change to an interface call?
	itemsPtr, err := GetItemsPtr(obj)
	if err != nil {
		return err
	}
	items, err := conversion.EnforcePtr(itemsPtr)
	if err != nil {
		return err
	}
	len := items.Len()
	if len == 0 {
		return nil
	}
	takeAddr := false
	if elemType := items.Type().Elem(); elemType.Kind() != reflect.Ptr && elemType.Kind() != reflect.Interface {
		if !items.Index(0).CanAddr() {
			return fmt.Errorf("unable to take address of items in %T for EachListItem", obj)
		}
		takeAddr = true
	}

	for i := 0; i < len; i++ {
		raw := items.Index(i)
		if takeAddr {
			raw = raw.Addr()
		}
		switch item := raw.Interface().(type) {
		case *runtime.RawExtension:
			if err := fn(item.Object); err != nil {
				return err
			}
		case runtime.Object:
			if err := fn(item); err != nil {
				return err
			}
		default:
			obj, ok := item.(runtime.Object)
			if !ok {
				return fmt.Errorf("%v: item[%v]: Expected object, got %#v(%s)", obj, i, raw.Interface(), raw.Kind())
			}
			if err := fn(obj); err != nil {
				return err
			}
		}
	}
	return nil
}
1091375
func (toks *Toks) Iterate(t *html.Node) {
	for _, tok := range *toks {
		if tok.Match(t.Type, t.DataAtom) {
			tok.Callback(t)
		}
	}
}